Skip to content

chore: allow local frontend origins for CORS#99

Merged
tlarbals824 merged 1 commit intodevelopfrom
chore/allow-localhost-cors-prod
May 5, 2026
Merged

chore: allow local frontend origins for CORS#99
tlarbals824 merged 1 commit intodevelopfrom
chore/allow-localhost-cors-prod

Conversation

@tlarbals824
Copy link
Copy Markdown
Collaborator

@tlarbals824 tlarbals824 commented May 5, 2026

문제

현재 별도 개발 API 서버가 없어 로컬 Next.js 프론트에서 운영 API(https://api.vs.io.kr)를 직접 호출해 테스트해야 하는 상황입니다.

기존 production CORS 기본값은 운영 프론트 도메인만 허용했습니다.

https://vs.io.kr

그래서 로컬 프론트 개발 환경의 preflight 요청은 차단됩니다.

수정 내용

1. production CORS 기본 허용 origin에 로컬 프론트 origin 추가

wildcard(*)는 사용하지 않고, 필요한 로컬 origin만 명시적으로 추가했습니다.

https://vs.io.kr
http://localhost:3000
http://127.0.0.1:3000

APP_CORS_ALLOWED_ORIGINS를 명시하면 기존처럼 환경변수 값이 우선됩니다.

2. dev 프로필을 local 프로필로 정리

application-dev.ymlapplication-local.yml로 변경했습니다.

  • 로컬 H2 설정 유지
  • 로컬 OAuth dummy client 설정 포함
  • 로컬 CORS 설정 유지
  • 기본 active profile에서는 제거

3. test 전용 프로필 추가

src/test/resources/application-test.yml을 추가하고, context load 테스트는 @ActiveProfiles("test")를 사용하도록 분리했습니다.

4. openapi 프로필은 유지

API 클라이언트 생성에서 사용하는 application-openapi.yaml은 그대로 유지했습니다.

주의

allow-credentials=true 상태에서 운영 API가 localhost origin을 신뢰하게 되므로, 이 설정은 개발 API 서버나 프론트 BFF/proxy 흐름이 생기면 제거하는 것을 권장합니다.

검증

  • ./gradlew test --no-daemon
  • git diff --check

Permit the current production API to serve browser requests from local frontend dev origins while consolidating local-only Spring settings under the local profile. Keep the openapi profile intact for generated-client extraction.\n\nConstraint: The team has no separate development API server, so local Next.js testing needs to reach the deployed API.\nRejected: Wildcard CORS origins | unsafe with credentials enabled.\nConfidence: high\nScope-risk: moderate\nDirective: Remove localhost origins once a dedicated development API or BFF/proxy flow is available.\nTested: ./gradlew test --no-daemon; git diff --check\nNot-tested: Deployed CORS preflight after merge
@tlarbals824 tlarbals824 force-pushed the chore/allow-localhost-cors-prod branch from 83e171c to 14dcbad Compare May 5, 2026 07:40
@tlarbals824 tlarbals824 merged commit c9380c4 into develop May 5, 2026
@github-actions github-actions Bot deleted the chore/allow-localhost-cors-prod branch May 5, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant