简体   繁体   English

如何在chrome扩展和Node服务器之间启用跨源AJAX请求?

[英]How can I enable cross-origin AJAX requests between my chrome extension and my Node server?

In my background.js script, I'm making vanilla AJAX GET request using the XMLHttpRequest() object to my Node server (currently hosted on localhost ). 在我的background.js脚本中,我正在使用XMLHttpRequest()对象向我的节点服务器(当前托管在localhost )发出vanilla AJAX GET请求。 The Node server is using the npm package express to handle the GET request. Node服务器使用npm package express来处理GET请求。 However, background.js just returns the error: 但是, background.js只返回错误:

Access to XMLHttpRequest at 'localhost:80' from origin 'chrome-extension://jhccmehanjenpnjalilnihdmeignbcpn' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

Is it a permission I need to include in the manifest.json or something? 这是我需要包含在manifest.json的权限吗? Thanks! 谢谢!

@wOxxOm solved my problem in the comment above! @wOxxOm在上面的评论中解决了我的问题! I just forgot the http:// 我刚忘了http://

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

相关问题 Chrome扩展程序将数据发布到Rails服务器跨域XMLHttpRequest - Chrome Extension Post Data to Rails Server Cross-Origin XMLHttpRequest 如何在没有跨域隔离的情况下在 chrome 中启用 sharedArrayBuffer - How to enable sharedArrayBuffer in chrome without cross-origin isolation 用于 chrome 扩展的 iFrame 的跨域问题 - Cross-Origin issue with iFrame for chrome extension Chrome扩展程序中的跨域XHR失败 - Cross-Origin XHR failed in Chrome extension 如何在我的移动应用程序(cordova)上启用跨源资源共享,该API连接到API(在Yii中) - How to enable Cross-Origin Resource Sharing on my mobile app (cordova) that hooks up to an API (in Yii) 如何在 Chrome 上禁用 CORB(跨源读取阻止) - How can I disable CORB(Cross-Origin Read Blocking) on Chrome 通过 Chrome 扩展避免跨域策略 - Avoid cross-origin policy via Chrome extension Chrome扩展程序的跨域XMLHttpRequest返回状态0 - Cross-Origin XMLHttpRequest from Chrome Extension Returning Status 0 为什么 Chrome 扩展没有在跨域请求中设置 PHP Cookie? - Why is PHP Cookie not set in cross-origin request by the chrome extension? Node dev服务器和Spring Boot应用程序之间的跨域请求被阻止 - Cross-Origin Request Blocked between Node dev server and Spring Boot application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM