Skip to content

[FEAT] CORS 정책 수정 #95

Merged
LimdaeIl merged 1 commit intomainfrom
feat/cors-add
Dec 12, 2025
Merged

[FEAT] CORS 정책 수정 #95
LimdaeIl merged 1 commit intomainfrom
feat/cors-add

Conversation

@LimdaeIl
Copy link
Collaborator

@LimdaeIl LimdaeIl commented Dec 12, 2025

📝 Pull Request

📌 PR 종류

해당하는 항목에 체크해주세요.

  • 기능 추가 (Feature)
  • 버그 수정 (Fix)
  • 문서 수정 (Docs)
  • 코드 리팩터링 (Refactor)
  • 테스트 추가 (Test)
  • 기타 변경 (Chore)

✨ 변경 내용

프론트 개발 환경 url 또한 CORS 등록을 원하는 요청을 처리하기 위해 URL을 추가합니다.

🔍 관련 이슈

🧪 테스트

변경된 기능에 대한 테스트 범위 또는 테스트 결과를 작성해주세요.

  • 유닛 테스트 추가 / 수정
  • 통합 테스트 검증
  • 수동 테스트 완료

🚨 확인해야 할 사항 (Checklist)

PR을 제출하기 전에 아래 항목들을 확인해주세요.

  • 코드 포매팅 완료
  • 불필요한 파일/코드 제거
  • 로직 검증 완료
  • 프로젝트 빌드 성공
  • 린트/정적 분석 통과 (해당 시)

🙋 기타 참고 사항

리뷰어가 참고하면 좋을 만한 추가 설명이 있다면 적어주세요.

@LimdaeIl LimdaeIl self-assigned this Dec 12, 2025
Copilot AI review requested due to automatic review settings December 12, 2025 04:41
@LimdaeIl LimdaeIl added the ✨enhancement New feature or request label Dec 12, 2025
@LimdaeIl LimdaeIl moved this from Backlog to In progress in WeGo-Together Backend Dec 12, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 12, 2025

Walkthrough

CORS 설정에 새로운 허용 출처 "https://local.wego.monster"를 추가했습니다. CorsConfig.javaSecurityConfig.java 두 파일에서 동일한 도메인을 허용된 출처 목록에 추가했으며, 기존 설정과 제어 흐름에는 변화가 없습니다.

Changes

코호트 / 파일 변경 요약
CORS 설정 업데이트
src/main/java/team/wego/wegobackend/common/config/CorsConfig.java, src/main/java/team/wego/wegobackend/common/security/SecurityConfig.java
두 설정 파일에서 "https://local.wego.monster"을 허용된 CORS 출처 목록에 추가하여 개발 환경 도메인 접근을 허용하도록 설정

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • 두 파일 모두 동일한 패턴의 단순 문자열 추가 변경
  • CORS 허용 출처 목록에 새로운 도메인만 추가된 기계적 변경
  • 제어 흐름이나 보안 로직에 영향 없음

Possibly related issues

Possibly related PRs

Poem

🐰 로컬 도메인을 허용하니,
개발이 한결 편해졌네!
local.wego.monster 문을 열고,
개발자들의 마음도 활짝 열렸나봐! 🌟

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning 이 PR의 CORS 설정 변경사항은 연결된 이슈 #12(Spring Boot 환경 설정)와 #5(서버 배포 환경)의 요구사항과 직접적인 관계가 없습니다. 관련 이슈를 명시하거나, 이 변경이 이슈 #12 또는 #5의 어떤 요구사항을 해결하는지 설명해주세요.
Out of Scope Changes check ⚠️ Warning CORS 설정 추가는 연결된 이슈들(#12: Spring Boot 환경 설정, #5: 서버 배포 환경)의 명시된 요구사항 범위를 벗어난 변경으로 보입니다. PR 설명에서 이 변경이 이슈 #12 또는 #5와 어떤 관련이 있는지 명확히 문서화하거나 올바른 이슈를 연결하세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 CORS 정책 수정이라는 변경 내용과 관련이 있으며, 주요 변경 사항을 명확하게 요약하고 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/cors-add

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@LimdaeIl LimdaeIl merged commit 12e21bd into main Dec 12, 2025
4 of 5 checks passed
@LimdaeIl LimdaeIl deleted the feat/cors-add branch December 12, 2025 04:42
@github-project-automation github-project-automation bot moved this from In progress to Done in WeGo-Together Backend Dec 12, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e2ff53a and e42aa12.

📒 Files selected for processing (2)
  • src/main/java/team/wego/wegobackend/common/config/CorsConfig.java (1 hunks)
  • src/main/java/team/wego/wegobackend/common/security/SecurityConfig.java (1 hunks)

Comment on lines +19 to +20
"https://api.wego.monster",
"https://local.wego.monster"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

새로운 출처 추가는 적절하나, CORS 설정 중복 문제가 있습니다.

https://local.wego.monster 출처를 추가한 것은 양호하지만, SecurityConfig.java에서도 동일한 CORS 설정을 CorsConfigurationSource 빈으로 정의하고 있습니다. Spring Security가 활성화된 경우 SecurityConfig의 CORS 설정이 우선 적용되므로, 현재 CorsConfig 클래스의 설정은 무시될 수 있습니다.

CORS 설정을 SecurityConfig로 통합하여 단일 진실 공급원(Single Source of Truth)을 유지하는 것을 권장합니다.

다음과 같이 CorsConfig 클래스를 제거하고 SecurityConfig의 CORS 설정만 사용하도록 리팩터링하는 것을 고려하세요:

-@Configuration
-public class CorsConfig {
-    @Bean
-    public WebMvcConfigurer corsConfigurer() {
-        return new WebMvcConfigurer() {
-            @Override
-            public void addCorsMappings(CorsRegistry registry) {
-                registry.addMapping("/**")
-                    .allowedOrigins(
-                        "http://localhost:3000",
-                        "https://wego.monster",
-                        "https://api.wego.monster",
-                        "https://local.wego.monster"
-                    )
-                    .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
-                    .allowedHeaders("*")
-                    .allowCredentials(true)
-                    .maxAge(3600);
-            }
-        };
-    }
-}

또는 SecurityConfig에서 CORS 설정을 제거하고 이 파일만 사용하려면, SecurityConfig의 .cors() 설정을 제거해야 합니다.

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +72 to +73
"https://api.wego.monster",
"https://local.wego.monster"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, find the SecurityConfig.java file
find . -name "SecurityConfig.java" -type f

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 143


🏁 Script executed:

#!/bin/bash
# Search for application configuration files
fd -e yml -e yaml -e properties | grep -E "application.*\.(yml|yaml|properties)" | head -20

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 104


🏁 Script executed:

#!/bin/bash
# Read SecurityConfig.java to see the CORS configuration around lines 72-73
wc -l ./src/main/java/team/wego/wegobackend/common/security/SecurityConfig.java

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 146


🏁 Script executed:

#!/bin/bash
# Check for profile-based application configuration files
fd "application-.*\.(yml|yaml|properties)" src/main/resources/

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 52


🏁 Script executed:

#!/bin/bash
# Read SecurityConfig.java from line 60 onwards to see lines 72-73 in context
sed -n '60,83p' ./src/main/java/team/wego/wegobackend/common/security/SecurityConfig.java

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 901


🏁 Script executed:

#!/bin/bash
# Read application.yml to check current CORS configuration
cat src/main/resources/application.yml

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 1943


🏁 Script executed:

#!/bin/bash
# Search for all references to local.wego.monster in the codebase
rg "local\.wego\.monster" -C 2

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 1291


🏁 Script executed:

#!/bin/bash
# Search for any local development setup documentation
fd -e md -e txt -e properties | xargs rg -l "local|localhost|development" | head -10

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 52


🏁 Script executed:

#!/bin/bash
# Read CorsConfig.java to see the other CORS configuration
cat src/main/java/team/wego/wegobackend/common/config/CorsConfig.java

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 1164


🏁 Script executed:

#!/bin/bash
# Check for any documentation or comments about why there are two CORS configurations
rg -B 5 "CorsConfigurationSource|WebMvcConfigurer" src/main/java/team/wego/wegobackend/common/ | head -40

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 3618


🏁 Script executed:

#!/bin/bash
# Search for any references or imports to these CORS configs in other files
rg "CorsConfig|corsConfigurationSource" --type java | grep -v "^Binary"

Repository: WeGo-Together/WeGo_BackEnd

Length of output: 1281


두 CORS 설정 파일의 하드코딩된 로컬 도메인을 환경별 설정으로 분리가 필요합니다.

https://local.wego.monster를 허용 출처에 추가했으나, 다음 문제들이 있습니다:

  1. 코드 중복: 동일한 도메인 목록이 SecurityConfig.javaCorsConfig.java 두 파일에 하드코딩되어 있습니다. 둘 다 동일하게 수정해야 하며, 추후 유지보수 시에도 일관성 유지가 어렵습니다.

  2. 환경별 설정 분리 부재: 로컬 개발용 도메인을 프로덕션 코드에 하드코딩하는 것은 권장되지 않습니다. application.yml의 프로파일별 설정을 통해 환경에 따라 다른 허용 출처를 구성해야 합니다.

  3. 로컬 HTTPS 도메인 검증: 일반적으로 로컬 개발은 http://localhost 또는 http://127.0.0.1을 사용하며, HTTPS는 인증서 설정이 필요합니다. https://local.wego.monster 도메인이 실제로 로컬 개발 환경에서 접근 가능한지 확인이 필요합니다.

권장 수정 사항:

CorsConfig.javaSecurityConfig.java 모두에서 하드코딩된 도메인 목록을 제거하고, 대신 설정 파일에서 주입받도록 변경하세요:

application.yml:

cors:
  allowed-origins:
    - http://localhost:3000
    - https://wego.monster
    - https://api.wego.monster

application-local.yml:

cors:
  allowed-origins:
    - http://localhost:3000
    - https://wego.monster
    - https://api.wego.monster
    - https://local.wego.monster

CorsConfig.java와 SecurityConfig.java:

@Value("${cors.allowed-origins}")
private List<String> allowedOrigins;
🤖 Prompt for AI Agents
In src/main/java/team/wego/wegobackend/common/security/SecurityConfig.java
around lines 72-73 (and likewise update CorsConfig.java), remove the hardcoded
origin strings and instead load allowed origins from configuration; add a
cors.allowed-origins list to application.yml and application-local.yml (local
profile includes the extra local origin), inject it into both SecurityConfig and
CorsConfig (e.g. @Value or @ConfigurationProperties into a List<String>) and use
that list when building the CORS and security origin checks so environments
control allowed origins and duplication is eliminated.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new allowed origin https://local.wego.monster to the CORS configuration to enable cross-origin requests from this subdomain.

  • Added https://local.wego.monster to the list of allowed CORS origins
  • Updated both SecurityConfig and CorsConfig to maintain consistency

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main/java/team/wego/wegobackend/common/security/SecurityConfig.java Added https://local.wego.monster to the allowed origins list in the Spring Security CORS configuration
src/main/java/team/wego/wegobackend/common/config/CorsConfig.java Added https://local.wego.monster to the allowed origins list in the WebMvc CORS configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"https://wego.monster",
"https://api.wego.monster"));
"https://api.wego.monster",
"https://local.wego.monster"));
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The domain "https://local.wego.monster" suggests a local development environment. Consider whether this subdomain should be allowed in production. If this is intended only for local development, you might want to use environment-specific configuration (e.g., via application-{profile}.yml) to prevent exposing this origin in production environments.

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +20
"https://api.wego.monster",
"https://local.wego.monster"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The domain "https://local.wego.monster" suggests a local development environment. Consider whether this subdomain should be allowed in production. If this is intended only for local development, you might want to use environment-specific configuration (e.g., via application-{profile}.yml) to prevent exposing this origin in production environments.

Suggested change
"https://api.wego.monster",
"https://local.wego.monster"
"https://api.wego.monster"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEAT] CORS 정책 수정

1 participant

Comments