javascript:提取因通配符而被 CORS 策略阻止
javascript: fetch blocked by CORS policy because of wildcard
我正在尝试使用以下 api 使用 fetch 的端点:
https://api.guerrillamail.com/ajax.php?f=check_email&ip=${ip}&agent=${agent}
(outdated documentation)
当我设置 credentials: 'include'
时,出现以下错误:
Access to fetch at 'https://api.guerrillamail.com/ajax.php?...' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
我必须设置标志才能提交用于身份验证的 cookie。
谷歌搜索这个问题 1++ 小时后,我的理解如下:
CORS 必须在服务器端允许才能向其他域发出 "none simple" 请求,例如localhost => guerrillamail.com
为防止滥用,必须将变量 Access-Control-Allow-Origin
设置为允许发送请求的域。有效选项是“*”,这意味着所有来源都可以。
出于某种原因,尽管与 credentials: 'include
标志结合使用,但还是不行。
您知道为什么不允许这样做吗?
你知道我必须做什么才能完成请求吗?
我对此的理解正确吗?
您引用的文档不再适用。在那个旧文档中,API 是通过 HTTP 而不是 HTTPS 提供的。 CORS 不适用于 HTTP,不会成为问题。
在 latest documention 中,API 是通过 HTTPS 提供的。为了处理 CORS 要求,他们还删除了对 cookie 的需要,将其更改为作为请求的一部分发送的 subscr_token
和 sid_token
参数:
version 1.5, 30th May 2011
- Removed the requirement for cookies, added subscr_token and sid_token parameters
我正在尝试使用以下 api 使用 fetch 的端点:
https://api.guerrillamail.com/ajax.php?f=check_email&ip=${ip}&agent=${agent}
(outdated documentation)
当我设置 credentials: 'include'
时,出现以下错误:
Access to fetch at 'https://api.guerrillamail.com/ajax.php?...' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
我必须设置标志才能提交用于身份验证的 cookie。
谷歌搜索这个问题 1++ 小时后,我的理解如下:
CORS 必须在服务器端允许才能向其他域发出 "none simple" 请求,例如localhost => guerrillamail.com
为防止滥用,必须将变量 Access-Control-Allow-Origin
设置为允许发送请求的域。有效选项是“*”,这意味着所有来源都可以。
出于某种原因,尽管与 credentials: 'include
标志结合使用,但还是不行。
您知道为什么不允许这样做吗?
你知道我必须做什么才能完成请求吗?
我对此的理解正确吗?
您引用的文档不再适用。在那个旧文档中,API 是通过 HTTP 而不是 HTTPS 提供的。 CORS 不适用于 HTTP,不会成为问题。
在 latest documention 中,API 是通过 HTTPS 提供的。为了处理 CORS 要求,他们还删除了对 cookie 的需要,将其更改为作为请求的一部分发送的 subscr_token
和 sid_token
参数:
version 1.5, 30th May 2011
- Removed the requirement for cookies, added subscr_token and sid_token parameters