求大佬解惑,怎么设置都报错哎...
google 了解下 Access-Control-Request-Headers,大致是需要服务器响应头需要含有客户端发送的值才能通过跨域。 我尝试直接将客户端的值作为响应头返回回去还是报错,不知道还有哪里没有注意。
请求头:
请求方法:OPTIONS
Accept: */*
Accept-Language: zh-CN,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate, br
Access-Control-Request-Method: GET
Access-Control-Request-Headers: range,user-agent
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
TE: Trailers
响应头:
HTTP/2 200 OK
date: Mon, 24 Feb 2020 10:53:06 GMT
content-type: text/plain;charset=UTF-8
content-length: 0
access-control-allow-origin: *
access-control-request-headers: range,user-agent
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
vary: Accept-Encoding
server: cloudflare
X-Firefox-Spdy: h2
游览器报错: 已拦截跨源请求:同源策略禁止读取位于 x 的远程资源。(原因:来自 CORS 预检通道的 CORS 头 'Access-Control-Allow-Headers' 的令牌 'range' 无效)。
1
SunriseFox 2020-02-24 19:52:00 +08:00
为什么 Access-Control-Request-Headers 会出现在响应里面喵
|
2
rrfeng 2020-02-24 20:57:42 +08:00
响应应该是 allow-headers
|
3
randyo 2020-02-24 21:08:14 +08:00 via Android
|