From 14ef73a95f4f8a3f092eacdf954387322f3cee8a Mon Sep 17 00:00:00 2001 From: Wonder Date: Tue, 7 Oct 2025 01:27:56 +0800 Subject: [PATCH] =?UTF-8?q?Update:=20=E5=A2=9E=E5=8A=A0=20api-gateway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config-files/api-gateway.yml | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 config-files/api-gateway.yml diff --git a/config-files/api-gateway.yml b/config-files/api-gateway.yml new file mode 100644 index 0000000..3262206 --- /dev/null +++ b/config-files/api-gateway.yml @@ -0,0 +1,52 @@ +server: + port: 8080 +spring:: + application: + name: api-gateway + cloud: + gateway: + routes: + # 路由到service-producer服务 + - id: service-producer + uri: lb://service-producer + predicates: + - Path=/api/producer/** + filters: + - StripPrefix=2 + # 路由到service-consumer服务 + - id: service-consumer + uri: lb://service-consumer + predicates: + - Path=/api/consumer/** + filters: + - StripPrefix=2 + # 全局过滤器配置 + globalcors: + cors-configurations: + '[/**]': + allowedOrigins: "*" + allowedMethods: "*" + allowedHeaders: "*" + # 全局默认路由 + default-filters: + - AddResponseHeader=Access-Control-Allow-Origin,* + - AddResponseHeader=Access-Control-Allow-Methods,GET,POST,PUT,DELETE,OPTIONS + - AddResponseHeader=Access-Control-Allow-Headers,Content-Type,Authorization + # 服务发现配置 + discovery: + client: + simple: + instances: + eureka-server: + - uri: http://localhost:8761 + # 服务注册配置 + cloud: + config: + uri: http://localhost:8888 +# Eureka客户端配置 +eureka: + client: + service-url: + defaultZone: http://localhost:8761/eureka/ + instance: + prefer-ip-address: true \ No newline at end of file