Hapi.js与胶水CORS标头没有设置
好的,这就是我的胶水清单看起来的样子。你可以看到cors对象正在设置但是从前端app:localhost:3000运行时我一直收到这个愚蠢的错误。
Access to XMLHttpRequest at 'http://localhost:8082/api/v1/check_out_order' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
"glueManifest": {
"server": {
"port": 8082,
"routes": {
"cors": {
"origin": ["*"],
"additionalHeaders": ["cache-control", "x-requested-with"]
}
}
},
任何可能为我提供解决方案的人都会受到赞赏! TIA!
回答如下:试试这个:var server= new Hapi.Server({ port: 8082, routes: { cors: true }});
Hapi.js与胶水CORS标头没有设置
好的,这就是我的胶水清单看起来的样子。你可以看到cors对象正在设置但是从前端app:localhost:3000运行时我一直收到这个愚蠢的错误。
Access to XMLHttpRequest at 'http://localhost:8082/api/v1/check_out_order' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
"glueManifest": {
"server": {
"port": 8082,
"routes": {
"cors": {
"origin": ["*"],
"additionalHeaders": ["cache-control", "x-requested-with"]
}
}
},
任何可能为我提供解决方案的人都会受到赞赏! TIA!
回答如下:试试这个:var server= new Hapi.Server({ port: 8082, routes: { cors: true }});