【发布时间】:2018-07-20 01:31:34
【问题描述】:
我在节点版本 v8.9.4 中面临 CORS 问题。 错误是 -
Response to preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://localhost:4200' is therefore not allowed
access.
在前端我使用 angular4 并在我的标题中放置了下面的代码,但仍然面临问题。
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE,
OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-
Token');
【问题讨论】:
标签: javascript node.js angular angular2-forms hapijs