在Sails.js应用和NGINX反向代理

时间:2017-08-28 16:07:16

标签: node.js nginx cors sails.js reverse-proxy

Sails.js cors配置

module.exports.cors = {

    /***************************************************************************
    *                                                                          *
    * Allow CORS on all routes by default? If not, you must enable CORS on a   *
    * per-route basis by either adding a "cors" configuration object to the    *
    * route config, or setting "cors:true" in the route config to use the      *
    * default settings below.                                                  *
    *                                                                          *
    ***************************************************************************/

    allRoutes: true,

    /***************************************************************************
    *                                                                          *
    * Which domains which are allowed CORS access? This can be a               *
    * comma-delimited list of hosts (beginning with http:// or https://) or    *
    * "*" to allow all domains CORS access.                                    *
    *                                                                          *
    ***************************************************************************/

    origin: '*',

    /***************************************************************************
    *                                                                          *
    * Allow cookies to be shared for CORS requests?                            *
    *                                                                          *
    ***************************************************************************/

    // credentials: true,

    /***************************************************************************
    *                                                                          *
    * Which methods should be allowed for CORS requests? This is only used in  *
    * response to preflight requests (see article linked above for more info)  *
    *                                                                          *
    ***************************************************************************/

    methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',

    /***************************************************************************
    *                                                                          *
    * Which headers should be allowed for CORS requests? This is only used in  *
    * response to preflight requests.                                          *
    *                                                                          *
    ***************************************************************************/

    headers: 'content-type, Authorization'

  };

我也尝试过设置nginx

这是日志 - > ' Access-Control-Allow-Origin'标头包含无效值''。起源' http://localhost:8100'因此不允许访问。

我做错了什么?

0 个答案:

没有答案