auth.js:84交叉来源读取阻塞(CORB)阻止跨原点响应 http://myserver/auth 与MIME类型的应用程序/json。
这也不适用于Firefox,尽管Firefox错误消息更通用。奇怪的是,Firefox的网络面板显示,我想要的响应实际上被传递了,浏览器只是不接受将它传递给我的JavaScript代码的响应。
这是从我的 krakend.json 文件中设置的CORS:
krakend.json
"github_com/devopsfaith/krakend-cors": { "allow_origins": ["http://localhost:61552"], "allow_headers": ["Origin", "Authorization", "Content-Type", "Accept", "X-Auth-Token", "Referer", "User-Agent"], "expose_headers": ["Content-Type", "Content-Length"], "allow_credentials": true, "allow_methods": ["GET", "HEAD", "POST", "OPTIONS"] }
这是被调用的特定端点:
"endpoints": [{ "endpoint": "/auth", "method": "POST", "output_encoding": "no-op", "extra_config": { "github.com/devopsfaith/krakend-ratelimit/juju/router": { "maxRate": 20, "clientMaxRate": 8, "strategy": "ip" "backend": [{ "url_pattern": "/connect/token", "encoding": "no-op", "sd": "dns", "host": ["identity-server.service.consul"], "disable_host_sanitize": true },
我的JavaScript请求如下所示:
xhr.open('POST', url); xhr.setRequestHeader('Accept', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');