参考配置
spring:
cloud:
gateway:
globalcors:
add-to-simple-url-handler-mapping: true
cors-configurations:
'[/**]':
allow-credentials: true
allowed-methods: [GET,HEAD,POST,PUT,DELETE,PATCH,TRACE,CONNECT]
allowed-origin-patterns:
- http://localhost:*
- https://*.example.com
discovery:
locator:
enabled: true
注意,其中的cors只会处理gateway转发给其他微服务的请求,并不包含发送给gateway服务本身的请求(例如开启actuator后生成的端点,gateway下自定义添加的controller等)
网友评论