通过 StackSaga 管理服务器访问服务时出现 CORS 错误

问题描述 投票:0回答:1

我尝试通过 StackSaga 管理服务器访问我的订单服务。该请求也通过 Spring Cloud API 网关。但不幸的是,我一直在浏览器控制台上得到

CORS error

spring-boot spring-cloud spring-cloud-gateway stacksaga
1个回答
0
投票

当您尝试通过 Spring Cloud API 网关访问 stacksaga 事件存储 API 时,您必须允许管理服务器的起源。例如,如果管理服务器在端口

localhost:4444
上运行,则必须允许通过包含
stacksaga/
的 API 网关的所有端点的起源(因为所有事件存储 API 端点均以
stacksaga
开头) )就像下面的
yaml
文件(或 .properties 文件)中一样。

spring:
  cloud:
    gateway:
      globalcors:
        corsConfigurations:
          '[/*/stacksaga/**]':
            allowedOrigins:
              - "http://localhost:44441"
            allowedMethods: "*"
            allowedHeaders: "*"
      default-filters:
        - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin

这其实和StackSaga框架无关。阅读本文档了解更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.