禁止对飞行前403的响应 [英] Response for preflight 403 forbidden
问题描述
我一直在尝试向服务器发布一个简单的iron-ajax
帖子,但是在预检调用中一直失败.对于我一生,我不知道发生了什么,服务器上的所有CORS标头似乎都是正确的.
Response headers
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Content-Type
Access-Control-Allow-Methods:GET, POST, PUT, OPTIONS
Access-Control-Allow-Origin:*
cache-control:must-revalidate, private, no-cache, no-store, max-age=0
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:138
Content-Type:text/html
Request headers
Accept:*/*
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:POST
Cache-Control:no-cache
Connection:keep-alive
该请求确实是从本地主机发出的,但我本以为*
应该解决这个问题.
控制台中显示的错误是:
OPTIONS https://... 403 (Forbidden)
和
XMLHttpRequest cannot load https://.... Response for preflight has invalid HTTP status code 403
感谢任何帮助/建议.
403响应状态表示服务器后端未配置为处理OPTIONS
请求,而不仅仅是CORS预检OPTIONS
请求. >
服务器必须以2xx成功状态(通常为200或204)响应OPTIONS
请求.
如果服务器不这样做,则配置为发送的Access-Control-*
标头没有区别.配置服务器以正确方式处理OPTIONS
请求(发送200或204成功消息)的答案取决于其运行的服务器软件
I've been trying to make a simple iron-ajax
post to the server, but it keeps failing at the preflight call. For the life of me I can't figure out what's going on, all the CORS headers seem to be correct on the server.
Response headers
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Content-Type
Access-Control-Allow-Methods:GET, POST, PUT, OPTIONS
Access-Control-Allow-Origin:*
cache-control:must-revalidate, private, no-cache, no-store, max-age=0
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:138
Content-Type:text/html
Request headers
Accept:*/*
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:POST
Cache-Control:no-cache
Connection:keep-alive
The request is indeed made from localhost, but I would have thought that the *
should take care of that.
Errors that are showing up in the console are:
OPTIONS https://... 403 (Forbidden)
and
XMLHttpRequest cannot load https://.... Response for preflight has invalid HTTP status code 403
Any help/advice is appreciated.
The 403 response status indicates a general problem with the server backend not being configured to handle OPTIONS
requests, not just CORS preflight OPTIONS
requests.
The server must respond to OPTIONS
requests with a 2xx success status—typically 200 or 204.
If the server doesn’t do that, it makes no difference what Access-Control-*
headers you have it configured to send. And the answer to configuring the server to handle OPTIONS
requests in the right way—to send a 200 or 204 success message—depends on what server software it’s running
这篇关于禁止对飞行前403的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!