限制CORS不适用于POST请求

我正在使用restify为我的应用程序。 交叉原点请求对于使用restify的CORS的GET工作正常,但对POST请求显示以下错误。

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:1337/path/add. This can be fixed by moving the resource to the same domain or enabling CORS. 

我使用的启用CORS的代码是:

  server.use(restify.CORS()); 

根据其文件 。 任何人都可以build议我如何使POST请求工作

今天早上我遇到了同样的问题,对我有效的改变是改变了:

 server.use(restify.CORS()); 

至:

 server.pre(restify.CORS()); server.use(restify.fullResponse()); 

服务器。 预先是重要的一点。 我在文档中发现了一个与错误有关的错误:

https://github.com/mcavage/node-restify/issues/573

同样的问题在这里解决了这个问题:

 restify.CORS.ALLOW_HEADERS.push('authorization'); server.pre(restify.CORS()); server.use(restify.fullResponse()); 

假设您有一个授权标题,例如一个不记名标记。