參考配置
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轉(zhuǎn)發(fā)給其他微服務(wù)的請求,并不包含發(fā)送給gateway服務(wù)本身的請求(例如開啟actuator后生成的端點驻襟,gateway下自定義添加的controller等)