无法从WhatsApp Web聊天控制台发出API请求?
- 访问WhatsApp Web聊天( https://web.whatsapp.com/ )
- 获取API呼叫
(async () => {
const response = await fetch(
`https://jsonplaceholder.typicode.com/posts/1`
);
const json = await response.json();
console.log(json);
})();
- :控制台返回此错误:
VM285:2 Refused to connect to 'https://jsonplaceholder.typicode.com/posts/1'
because it violates the document's Content Security Policy.
PS:对Telegram Web Chat(
有可能有能力使其适用于WhatsApp页面吗?
更新:您可以使用 Chrome扩展以绕过内容安全策略
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Web.whatsapp.com的内容安全策略当前定义了与以下指令的连接:
由于JSONPLACEHOLDER.TYPICODE.com不在该允许列表上,因此被阻止了,您无能为力。
电报显然没有为内容安全策略标题服务,而不是限制此类连接。
The Content Security Policy of web.whatsapp.com currently defines connects with the following directive:
As jsonplaceholder.typicode.com is not on that allowlist, it is blocked and there is nothing you can do about that.
Telegram is apparently not serving a Content Security Policy header and not restricting such connects.