预检 403 禁止响应
Response for preflight 403 forbidden
我一直在尝试对服务器进行简单的 iron-ajax
post,但它在预检调用中一直失败。对于我的生活,我无法弄清楚发生了什么,所有 CORS headers 在服务器上似乎都是正确的。
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
请求确实是从 localhost 发出的,但我认为 *
应该会处理这个问题。
控制台中显示的错误是:
OPTIONS https://... 403 (Forbidden)
和
XMLHttpRequest cannot load https://.... Response for preflight has invalid HTTP status code 403
任何 help/advice 不胜感激。
403 响应状态表示服务器后端未配置为处理 OPTIONS
请求的一般问题,而不仅仅是 CORS 预检 OPTIONS
请求。
服务器必须响应 OPTIONS
具有 2xx 成功状态的请求——通常为 200 或 204。
如果服务器不这样做,那么 Access-Control-*
headers 您将其配置为发送什么都没有关系。将其配置为以正确的方式处理 OPTIONS
请求(发送 200 或 204 成功消息)的答案取决于它是什么服务器软件 运行。
我一直在尝试对服务器进行简单的 iron-ajax
post,但它在预检调用中一直失败。对于我的生活,我无法弄清楚发生了什么,所有 CORS headers 在服务器上似乎都是正确的。
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
请求确实是从 localhost 发出的,但我认为 *
应该会处理这个问题。
控制台中显示的错误是:
OPTIONS https://... 403 (Forbidden)
和
XMLHttpRequest cannot load https://.... Response for preflight has invalid HTTP status code 403
任何 help/advice 不胜感激。
403 响应状态表示服务器后端未配置为处理 OPTIONS
请求的一般问题,而不仅仅是 CORS 预检 OPTIONS
请求。
服务器必须响应 OPTIONS
具有 2xx 成功状态的请求——通常为 200 或 204。
如果服务器不这样做,那么 Access-Control-*
headers 您将其配置为发送什么都没有关系。将其配置为以正确的方式处理 OPTIONS
请求(发送 200 或 204 成功消息)的答案取决于它是什么服务器软件 运行。