如何在sailsjs api上正确configurationCORS

我的应用程序由前端的angularjs和后端的sailsjs组成。 我正在尝试在后端configurationCORS,但没有成功。 我希望地址api.example.com上的后端只能从地址为blog.example.com的前端访问。 我在sails config / cors.js上的设置是:

allRoutes: false, origin: 'http://blog.example.com', credentials: true, methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD', headers: 'content-type' 

结果是,如果我input到浏览器地址栏api.example.com,而不是我的前端,我的后端可以自由访问! 在Chrome中,我得到的答案是:“Access-Control-Allow-Origin'标头包含无效值''”,Firefox只发送空的Response Body。 我也尝试在config / routes.js中configurationcors,但也没有成功。 任何帮助表示赞赏!

你想allRoutes: true除非你启用路由的路由基础。

http://sailsjs.org/documentation/concepts/security/cors