CORS

2023 年 9 月 15 日

当响应的是附带身份凭证的请求时,服务端必须明确  Access-Control-Allow-Origin  的值,而不能使用通配符“*”。

Access-Control-Max-Age  给出了在不发送另一个预检请求的情况下可以缓存对预检请求的响应的时间(以秒为单位)的值。默认值为 5 秒。

尽管第 10 行包含针对  https://bar.other  上的内容的 Cookie,但如果 bar.other 未使用  Access-Control-Allow-Credentials : true  进行响应(第 16 行),则响应将为会被忽略并且不会提供给 Web 内容。

如果响应中的  Access-Control-Allow-Origin  值是“ * ”通配符而不是实际来源,则响应中的任何  Set-Cookie  响应标头都不会设置 cookie 。

参考


Simple header is Old term for CORS-safelisted request header.

CORS-safelisted request header is one of the following HTTP headers:
CORS 安全列表请求标头是以下 HTTP 标头之一:

When containing only these headers (and values that meet the additional requirements laid out below), a request doesn’t need to send a preflight request in the context of CORS.
当仅包含这些标头(以及满足下面列出的附加要求的值)时,请求不需要在 CORS 上下文中发送预检请求。

参考

OPTIONS - HTTP | MDN

To find out which request methods a server supports, one can use the curl command-line program to issue an OPTIONS request:
要了解服务器支持哪些请求方法,可以使用  curl  命令行程序发出  OPTIONS  请求:

curl -X OPTIONS https://example.org -i

[[HTTP 请求方法]]