Files
dc-observatio/config-repo/pcp-gateway-service.yaml
T
Дмитрий Соловьев 3c4ebcd7d3 refactor(cors): централизовать CORS на gateway, убрать per-service из pcp-ui-service
CORS-политика (allowedOriginPatterns:* + allowCredentials) переезжает в единый
globalcors на pcp-gateway-service. После сворачивания фронта на gateway браузер
ходит к бэкендам только через него (same-origin via Vite/nginx), поэтому
per-service CORS в pcp-ui-service/WebConfig.kt стал мёртвым грузом. globalcors
оставлен как страховка от cross-origin напрямую к gateway.
2026-06-10 14:04:29 +03:00

102 lines
3.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
spring:
boot:
admin:
client:
instance:
service-base-url: ${pcp.services.gateway}
management-base-url: ${pcp.services.gateway}
cloud:
gateway:
server:
# WebFlux-вариант Spring Cloud Gateway (Boot 4 / Spring Cloud 2025.1).
webflux:
# CORS теперь живёт ТОЛЬКО здесь — единая точка на edge. Раньше дублировался
# per-service (pcp-ui-service/WebConfig.kt), но после сворачивания фронта на
# gateway браузер ходит к бэкендам строго через него. Страховка от cross-origin
# к самому gateway (dev напрямую, LAN-адрес рабочей станции): allowedOriginPatterns
# "*" совместим с allowCredentials=true (в отличие от allowedOrigins "*").
globalcors:
cors-configurations:
'[/**]':
allowedOriginPatterns: "*"
allowedMethods: "*"
allowedHeaders: "*"
allowCredentials: true
maxAge: 3600
routes:
# --- Доменные сервисы. Префикс /api/pcp-<x> СРЕЗАЕТСЯ (StripPrefix=2 убирает
# 2 сегмента: api + pcp-<x>), т.е. /api/pcp-tgu/api/plans -> бэкенд /api/plans.
# Это ровно семантика прежнего vite-rewrite. Цели берём из реестра pcp.services.*.
- id: tgu
uri: ${pcp.services.tgu}
predicates:
- Path=/api/pcp-tgu/**
filters:
- StripPrefix=2
- id: ballistics
uri: ${pcp.services.ballistics}
predicates:
- Path=/api/pcp-ballistics/**
filters:
- StripPrefix=2
- id: mission
uri: ${pcp.services.mission}
predicates:
- Path=/api/pcp-mission/**
filters:
- StripPrefix=2
- id: request
uri: ${pcp.services.request}
predicates:
- Path=/api/pcp-request/**
filters:
- StripPrefix=2
- id: complex
uri: ${pcp.services.complex-mission-service}
predicates:
- Path=/api/pcp-complex/**
filters:
- StripPrefix=2
# --- Станции: путь СОХРАНЯЕМ (в vite было без rewrite) — без StripPrefix.
- id: stations
uri: ${pcp.services.stations}
predicates:
- Path=/api/stations/**
# --- Общий catch-all /api/** -> ui-service. Матчится ПОСЛЕДНИМ (order выше).
- id: ui-catch-all
uri: ${pcp.services.ui}
predicates:
- Path=/api/**
order: 1
# Валидация JWT на edge. По умолчанию ВЫКЛЮЧЕНА (anonymous, как сейчас работает фронт).
# Для закрытого контура: GATEWAY_JWT_ENABLED=true И задать issuer через env
# SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI=<realm new-start>.
# Issuer намеренно НЕ объявлен здесь: пустое значение заставило бы автоконфиг поднимать
# JwtDecoder и падать на старте.
gateway:
security:
jwt-enabled: ${GATEWAY_JWT_ENABLED:false}
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus
---
spring:
config:
activate:
on-profile: local
server:
port: ${pcp.ports.gateway:7080}
---
spring:
config:
activate:
on-profile: dev
server:
port: ${pcp.ports.gateway:8080}