Graphql 从另一子域访问时,CORS策略已阻止对获取的访问

Graphql 从另一子域访问时,CORS策略已阻止对获取的访问,graphql,aws-fargate,aws-elb,aws-application-load-balancer,Graphql,Aws Fargate,Aws Elb,Aws Application Load Balancer,我在尝试从服务访问graphql url时遇到以下错误 POST https://subdomain-a.abc.com/graphql 504 Access to fetch at 'https://subdomain-a.abc.com/graphql' from origin 'https://subdomain-b.abc.com/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is

我在尝试从服务访问graphql url时遇到以下错误

POST https://subdomain-a.abc.com/graphql 504

Access to fetch at 'https://subdomain-a.abc.com/graphql' from origin 'https://subdomain-b.abc.com/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
这两项服务都在Fargate的同一个aws帐户上运行,ELB位于它们前面。路由53正在将请求重定向到ELB


我在谷歌上搜索到的大多数答案都与S3 bucket有关,但我的设置并不是这样。请告诉我是否可以提供更多详细信息。

您的GraphQL服务器需要将添加到其响应中


这是一篇很好且全面的文章,介绍了CORS的功能以及您为什么需要它

Ah。我猜是
POSThttps://subdomain-a.abc.com/graphql 504
错误是因为graphql响应中缺少响应头?很可能是。您会发现,您可以使用CURL之类的命令行工具访问API,因为它不执行浏览器需要执行的飞行前检查,因此它忽略了CORS要求。更多信息,请参阅文档。-请记住,该服务还必须在http选项响应中返回正确的CORS头,因为这是浏览器在飞行前使用的。谢谢你的澄清,太好了!一旦你确认这是有效的,那么你会接受答案吗?或者如果它不起作用,你会问更多的澄清问题吗