Updated gateway cors

This commit is contained in:
2026-03-17 20:22:12 +03:00
parent b3351c88ff
commit 5664e30b91
2 changed files with 84 additions and 90 deletions
+42 -45
View File
@@ -15,52 +15,49 @@ spring:
# 3. Gateway Routing (Modern WebFlux Namespace) # 3. Gateway Routing (Modern WebFlux Namespace)
cloud: cloud:
gateway: gateway:
globalcors: server:
cors-configurations: webflux:
'[/**]': globalcors:
allowedOrigins: cors-configurations:
- "http://localhost:3000" '[/**]': # URL pattern to apply the configuration to
- "https://kilimo.farm" allowedOrigins: # Allows requests from a specific origin
- "https://vm-qpse3mho5qps7fj2kw0hzy.vusercontent.net" - "*"
allowedMethods: allowedMethods:
- GET - "*"
- POST allowedHeaders:
- PUT - "*" # Allows all headers
- DELETE allowCredentials: false # Allows the browser to send cookies/auth headers
- OPTIONS maxAge: 3600 # Cache the preflight response for 1 hour
allowedHeaders: routes:
- "*" - id: kilimo_core_service
allowCredentials: true uri: http://localhost:9081
maxAge: 3600 # cache preflight response for 1 hour predicates:
- Path=/core/**
- Method=GET,POST,PUT,DELETE,OPTIONS
filters:
- RewritePath=/core/(?<path>.*), /$\{path}
- name: AuthFilter
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 10
redis-rate-limiter.burstCapacity: 20
key-resolver: "#{@userKeyResolver}"
routes: - id: kilimo_assistant_service
- id: kilimo_core_service uri: http://localhost:9082
uri: http://localhost:9081 predicates:
predicates: - Path=/assistant/**
- Path=/core/** - Method=GET,POST,PUT,DELETE,OPTIONS
- Method=GET,POST,PUT,DELETE,OPTIONS filters:
filters: - RewritePath=/assistant/(?<segment>.*), /${segment}
- RewritePath=/core/(?<path>.*), /$\{path} - name: AuthFilter
- name: AuthFilter - name: RequestRateLimiter
- name: RequestRateLimiter args:
args: redis-rate-limiter.replenishRate: 10
redis-rate-limiter.replenishRate: 10 redis-rate-limiter.burstCapacity: 20
redis-rate-limiter.burstCapacity: 20 key-resolver: "#{@userKeyResolver}"
key-resolver: "#{@userKeyResolver}" config:
enabled: false
- id: kilimo_assistant_service
uri: http://localhost:9082
predicates:
- Path=/assistant/**
- Method=GET,POST,PUT,DELETE,OPTIONS
filters:
- RewritePath=/assistant/(?<segment>.*), /${segment}
- name: AuthFilter
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 10
redis-rate-limiter.burstCapacity: 20
key-resolver: "#{@userKeyResolver}"
# 4. Actuator for Troubleshooting # 4. Actuator for Troubleshooting
management: management:
+42 -45
View File
@@ -15,52 +15,49 @@ spring:
# 3. Gateway Routing (Modern WebFlux Namespace) # 3. Gateway Routing (Modern WebFlux Namespace)
cloud: cloud:
gateway: gateway:
globalcors: server:
cors-configurations: webflux:
'[/**]': globalcors:
allowedOrigins: cors-configurations:
- "http://localhost:3000" '[/**]': # URL pattern to apply the configuration to
- "https://kilimo.farm" allowedOrigins: # Allows requests from a specific origin
- "https://vm-qpse3mho5qps7fj2kw0hzy.vusercontent.net" - "*"
allowedMethods: allowedMethods:
- GET - "*"
- POST allowedHeaders:
- PUT - "*" # Allows all headers
- DELETE allowCredentials: false # Allows the browser to send cookies/auth headers
- OPTIONS maxAge: 3600 # Cache the preflight response for 1 hour
allowedHeaders: routes:
- "*" - id: kilimo_core_service
allowCredentials: true uri: http://localhost:9081
maxAge: 3600 # cache preflight response for 1 hour predicates:
- Path=/core/**
- Method=GET,POST,PUT,DELETE,OPTIONS
filters:
- RewritePath=/core/(?<path>.*), /$\{path}
- name: AuthFilter
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 10
redis-rate-limiter.burstCapacity: 20
key-resolver: "#{@userKeyResolver}"
routes: - id: kilimo_assistant_service
- id: kilimo_core_service uri: http://localhost:9082
uri: http://localhost:9081 predicates:
predicates: - Path=/assistant/**
- Path=/core/** - Method=GET,POST,PUT,DELETE,OPTIONS
- Method=GET,POST,PUT,DELETE,OPTIONS filters:
filters: - RewritePath=/assistant/(?<segment>.*), /${segment}
- RewritePath=/core/(?<segment>.*), /${segment} - name: AuthFilter
- name: AuthFilter - name: RequestRateLimiter
- name: RequestRateLimiter args:
args: redis-rate-limiter.replenishRate: 10
redis-rate-limiter.replenishRate: 10 redis-rate-limiter.burstCapacity: 20
redis-rate-limiter.burstCapacity: 20 key-resolver: "#{@userKeyResolver}"
key-resolver: "#{@userKeyResolver}" config:
enabled: false
- id: kilimo_assistant_service
uri: http://localhost:9082
predicates:
- Path=/assistant/**
- Method=GET,POST,PUT,DELETE,OPTIONS
filters:
- RewritePath=/assistant/(?<segment>.*), /${segment}
- name: AuthFilter
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 10
redis-rate-limiter.burstCapacity: 20
key-resolver: "#{@userKeyResolver}"
# 4. Actuator for Troubleshooting # 4. Actuator for Troubleshooting
management: management: