gpt4 book ai didi

angularjs - "Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource."

转载 作者:太空宇宙 更新时间:2023-11-04 02:53:10 24 4
gpt4 key购买 nike

我正在从 localhost:8000 提供 Angular 应用程序,并从 localhost:3000 提供 Node 后端。我在页面加载和我的前端日志上运行一个 $http.get

仅协议(protocol)方案支持跨源请求:http、data、chrome、chrome-extension、https、chrome-extension-resource。

有很多关于此的帖子,但他们都说“不要直接在浏览器中打开你的文件”,我正在为他们提供服务,而不是打开它们。

我的后端配置为 CORS,并且通过 Postman 访问路由时路由可以工作。

前端:

controller

后端:

Backend

错误:

enter image description here

host + '/' 只是一个引用“localhost:3000”的常量

最佳答案

您的 URL 缺少方案 (http:)。您正在尝试使用相对 URL,该 URL 解析为类似 file:///blah/blah/blah/localhost:3000 的内容……正如错误消息所示,您无法从 file: URL 加载数据,因为那里不支持 CORS。使用正确的 URL。

关于angularjs - "Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36459997/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com