![](/img/trans.png)
[英]Azure Function App : Error when loading V3 in portal for fresh function app?
[英]Getting CORS error when communicating with Azure HTTP-triggered function v3 in docker
我的 docker .env
文件(环境定义文件)具有以下环境变量,以适应来自 angular 应用程序的传入 Web API 调用:
CORS_ALLOWED_ORIGINS='["http://localhost:4200"]'
在 docker 组合文件中定义的这个 Azure Function App v3 的方式是按照以下代码片段:
myhttpfunction:
image: ${DOCKER_REGISTRY-}httptriggeredfunc
container_name: azurefunctions
build:
context: .
dockerfile: app/HttpFunctions/Dockerfile
environment:
- CORS_ALLOWED_ORIGINS
ports:
- 9080:80
我可以通过 POSTMAN 向 function 应用程序发送 web 请求,但 angular 应用程序由于以下错误而失败:
CORS 策略已阻止从来源“http://localhost:4200”访问“http://localhost:9080/api/GetData”处的 XMLHttpRequest:对预检请求的响应未通过访问控制检查:无“访问” -Control-Allow-Origin' header 出现在请求的资源上。
这个问题的解决方案是什么?
显然我们需要合并一个反向代理来根据这篇 Github 帖子解决这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.