From 7f24e11d827a7e107afd74844e4a7e4b6ac5dfeb Mon Sep 17 00:00:00 2001 From: augustus Date: Tue, 17 Mar 2026 19:40:47 +0300 Subject: [PATCH] Updated gateway cors --- kilimo-gateway-localhost.yml | 74 ++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/kilimo-gateway-localhost.yml b/kilimo-gateway-localhost.yml index 540f301..21b70d6 100644 --- a/kilimo-gateway-localhost.yml +++ b/kilimo-gateway-localhost.yml @@ -15,36 +15,52 @@ spring: # 3. Gateway Routing (Modern WebFlux Namespace) cloud: gateway: - server: - webflux: # CRITICAL: Modern properties live under this node - routes: - # --- Core Service Route --- - - id: kilimo_core_service - uri: http://localhost:9081 - predicates: - - Path=/core/** - filters: - - RewritePath=/core/(?.*), /$\{segment} - - name: AuthFilter - - name: RequestRateLimiter - args: - redis-rate-limiter.replenishRate: 10 - redis-rate-limiter.burstCapacity: 20 - key-resolver: "#{@userKeyResolver}" + globalcors: + cors-configurations: + '[/**]': + allowedOrigins: + - "http://localhost:3000" + - "https://kilimo.farm" + - "https://vm-qpse3mho5qps7fj2kw0hzy.vusercontent.net" + allowedMethods: + - GET + - POST + - PUT + - DELETE + - OPTIONS + allowedHeaders: + - "*" + allowCredentials: true + maxAge: 3600 # cache preflight response for 1 hour - # --- Assistant Service Route --- - - id: kilimo_assistant_service - uri: http://localhost:9082 - predicates: - - Path=/assistant/** - filters: - - RewritePath=/assistant/(?.*), /$\{segment} - - name: AuthFilter - - name: RequestRateLimiter - args: - redis-rate-limiter.replenishRate: 10 - redis-rate-limiter.burstCapacity: 20 - key-resolver: "#{@userKeyResolver}" + routes: + - id: kilimo_core_service + uri: http://localhost:9081 + predicates: + - Path=/core/** + - Method=GET,POST,PUT,DELETE,OPTIONS + filters: + - RewritePath=/core/(?.*), /$\{segment} + - name: AuthFilter + - name: RequestRateLimiter + args: + redis-rate-limiter.replenishRate: 10 + redis-rate-limiter.burstCapacity: 20 + key-resolver: "#{@userKeyResolver}" + + - id: kilimo_assistant_service + uri: http://localhost:9082 + predicates: + - Path=/assistant/** + - Method=GET,POST,PUT,DELETE,OPTIONS + filters: + - RewritePath=/assistant/(?.*), /$\{segment} + - name: AuthFilter + - name: RequestRateLimiter + args: + redis-rate-limiter.replenishRate: 10 + redis-rate-limiter.burstCapacity: 20 + key-resolver: "#{@userKeyResolver}" # 4. Actuator for Troubleshooting management: