Abh*_*wal 5 firebase google-cloud-functions
我目前的用例很简单,我只需要向我在本地开发的云功能发出 post 请求。
问题是,当我开火时
firebase serve
Run Code Online (Sandbox Code Playgroud)
主机部署在localhost:5000
和云功能部署在localhost:5001
由于港口不同,它们都来自不同的来源。因此,当浏览器发送初始预检请求时,它失败并显示错误消息
Failed to load http://localhost:5001/projectname/region/sendEnquiry: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5000' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)
如何设置用于本地测试的标头?(同样,我不是专业人士,我猜当我决定在生产中部署时我会有相同的起源。如果没有,无论如何我仍然需要解决方案)
谢谢。
请注意,服务器和云功能是不同的服务,并且始终位于不同的端口。
CORS确实是由跨域问题引发的。如果都是本地的,就不应该真正存在跨域违规。
您没有提供有关您客户的任何信息,因此我们无法为您提供客户特定的解决方法。但是有几个 Chrome 扩展允许您禁用此类本地测试的 CORS 检查。搜索 Chrome 应用商店并找到适合您需求的应用商店。 https://chrome.google.com/webstore/search/cors?hl=en
| 归档时间: |
|
| 查看次数: |
1800 次 |
| 最近记录: |