简体   繁体   English

chrome devtools 扩展:Windows 上的 CORS 问题

[英]chrome devtools extension: CORS issues on windows

I'm building a chrome extension, where I add a panel in the devtools, from where I need to perform some ajax calls.我正在构建一个 chrome 扩展,我在 devtools 中添加了一个面板,我需要从那里执行一些 ajax 调用。

From what I read , I have to add my domain in the manifest.json permissions:根据我的阅读,我必须在 manifest.json 权限中添加我的域:

{
  ...
  "permissions": ["https://example.com/"]
}

And from within my devtools panel, I'm now able to perform api calls to the server.在我的 devtools 面板中,我现在可以对服务器执行 api 调用。

Except that on chrome-windows, nothing works.除了在 chrome-windows 上,没有任何效果。

From what I could observe:从我可以观察到的:

  • osX, linux: as long as the domain is authorized, everything works fine osX, linux:只要域授权,一切正常
  • windows: a pre-flight request is sent although the domain should be authorized. windows:虽然域应该被授权,但发送了一个飞行前请求。 It then fails, and everything is blocked然后它失败了,一切都被阻止了

Is there something I'm doing wrong here ?我在这里做错了吗?

Thanks,谢谢,

Ok, without changing anything the extension seems to behave as expected now.好的,在没有改变任何东西的情况下,扩展现在似乎表现得像预期的那样。

My guess is that there was some bug on chrome/windows that have been fixed since.我的猜测是 chrome/windows 上有一些错误已经被修复了。 Closing the question.结束问题。

If you're having trouble with regard to CORS in chrome extension, check the Cross-Origin XMLHttpRequest guide.如果您在 chrome 扩展中遇到 CORS 问题,请查看跨域 XMLHttpRequest指南。 There's a Requesting cross-origin permissions which details how you can implement cross-origin permissions.有一个请求跨域权限,其中详细说明了如何实现跨域权限。

There's also a handy chrome extension app called Allow-Control-Allow-Origin which might help when testing xhr requests.还有一个名为Allow-Control-Allow-Origin的方便的 chrome 扩展应用程序,它在测试 xhr 请求时可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM