最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

Hapi.js与胶水CORS标头没有设置

IT培训 admin 5浏览 0评论

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 }});

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论