跨域请求 withCredentials 为 True 时,服务器允许设置多个 allow-origin 域名吗?
是的,当请求中的 'withCredentials' 属性设置为 True 时,服务器可以设置多个域名为 'allow-origin'。这样,客户端可以在跨域请求中携带凭据,同时服务器也可以指定允许多个特定的域名来访问资源。
例如,服务器可以设置以下 'allow-origin' 头部:
Access-Control-Allow-Origin: 'http://example.com', 'https://another.example.com'
这将允许来自 'http://example.com' 和 'https://another.example.com' 的请求访问资源。
需要注意的是,当使用 'withCredentials' 时,服务器必须设置 'Access-Control-Allow-Credentials' 头部为 'true',以允许请求携带凭据。
原文地址: https://www.cveoy.top/t/topic/pmt0 著作权归作者所有。请勿转载和采集!