在application.yml中配置如下即可
spring:
application:
name: API-GATEWAY
cloud:
nacos:
server-addr: 你的nacos地址:8848
gateway:
routes:
- id: router
uri: lb:// 负载均衡写法
predicates:
- Path=/fu/ck/*
filters:
- StripPrefix=1
- Token=true
globalcors: #跨域问题
cors-configurations:
'[/**]':
allowedOrigins:
- "http://localhost:8080"
allowedHeaders:
- "*"
allowCredentials: true
maxAge: 360000
allowedMethods:
- GET
- POST
- DELETE
- PUT
- OPTIONS
- HEAD
default-filters:
- DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST