Conversation
📝 WalkthroughSummary by CodeRabbitChores
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughWebSocket 연결 안정화를 위해 CORS 허용 출처에 Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/backend-cicd.yml (1)
5-8: 특정 브랜치명 대신 패턴 사용 권장현재
feat/#164라는 구체적인 브랜치명이 CI/CD 트리거로 설정되어 있습니다. 이 브랜치가 병합된 후 삭제되면 해당 트리거는 더 이상 동작하지 않습니다.모든 기능 브랜치에 대해 일관된 자동 배포를 지원하려면,
feat/#164대신feat/**패턴으로 변경하는 것을 권장합니다. 이를 통해 향후 추가되는 기능 브랜치들도 자동으로 검증 및 배포 대상에 포함될 수 있습니다.제안 변경:
on: push: branches: - 'release/**' # 릴리즈 브랜치 - 'develop' # 개발 브랜치 - - 'feat/#164' + - 'feat/**' # 모든 기능 브랜치
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/backend-cicd.yml(1 hunks)src/main/resources/application.yml(1 hunks)
| cors: | ||
| allowed-origins: "http://localhost:3000" | ||
| allowed-origins: "http://localhost:3000, http://ipiece.store, https://ipiece.store" | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find WebSocketConfig file
echo "=== Searching for WebSocketConfig ==="
fd -e java -x grep -l "WebSocketConfig" {}
# Also search for files that reference cors or allowed-origins
echo -e "\n=== Searching for CORS configuration references ==="
rg -l "cors|allowed-origins" --type java
# Search for @ConfigurationProperties or @Value annotations related to CORS
echo -e "\n=== Searching for CORS property bindings ==="
rg -B5 -A10 "allowed-origins|@ConfigurationProperties.*cors|@Value.*cors" --type javaRepository: Woori-FISA-Go/IPiece-server
Length of output: 3621
🏁 Script executed:
#!/bin/bash
# Read the complete WebSocketConfig file
echo "=== WebSocketConfig.java ==="
cat -n src/main/java/com/masterpiece/IPiece/config/WebSocketConfig.java
# Read the complete SecurityConfig file
echo -e "\n=== SecurityConfig.java ==="
cat -n src/main/java/com/masterpiece/IPiece/config/SecurityConfig.javaRepository: Woori-FISA-Go/IPiece-server
Length of output: 9254
🏁 Script executed:
#!/bin/bash
# Search for any utility methods that might parse the allowedOrigins string
echo "=== Searching for allowedOrigins string parsing ==="
rg -B5 -A5 "allowedOrigins\s*\." --type java
# Check if there are any String.split or parsing utilities
echo -e "\n=== Searching for CORS origin parsing utilities ==="
rg -B3 -A3 "split|Stream|lambda" src/main/java/com/masterpiece/IPiece/config/SecurityConfig.java
# Check git history to see what the original CORS configuration looked like
echo -e "\n=== Check original CORS configuration in application.yml ==="
head -100 src/main/resources/application.yml | tail -50Repository: Woori-FISA-Go/IPiece-server
Length of output: 1226
CORS configuration will not work—requires parsing fix
The comma-separated format in application.yml is incompatible with how the code uses it. Both SecurityConfig and WebSocketConfig pass the entire string directly to methods that expect individual patterns:
- SecurityConfig (line 36):
config.addAllowedOriginPattern(allowedOrigins)receives the full string"http://localhost:3000, http://ipiece.store, https://ipiece.store"as a single regex pattern, which will fail to match any actual origin headers. - WebSocketConfig (line 29):
registry.addEndpoint("/ws").setAllowedOriginPatterns(allowedOrigins)has the same issue.
Required fix: Split the comma-separated string before use:
// In SecurityConfig.corsConfigurationSource()
Arrays.stream(allowedOrigins.split(",\\s*"))
.forEach(config::addAllowedOriginPattern);
// In WebSocketConfig.registerStompEndpoints()
registry.addEndpoint("/ws")
.setAllowedOriginPatterns(allowedOrigins.split(",\\s*"))
.withSockJS();🤖 Prompt for AI Agents
In src/main/resources/application.yml around lines 58 to 60, the CORS
allowed-origins is defined as a single comma-separated string which the code
then passes whole to methods expecting individual patterns (SecurityConfig line
36 and WebSocketConfig line 29); update the code to split that string on commas
with optional whitespace (e.g. split on ",\\s*") and then for SecurityConfig
iterate the resulting array and call addAllowedOriginPattern for each entry, and
for WebSocketConfig pass the split array into setAllowedOriginPatterns so each
origin is treated separately.
📌 개요
배포된 프론트엔드 환경(
ipiece.store)에서 백엔드 WebSocket 연결 시, CORS 정책으로 인해 연결이 거부되거나 HTTP Polling으로 전환되어 딜레이(렉)가 발생하는 문제를 해결합니다.👩💻 작업 내용
CORS 설정 업데이트 (
application.yml)allowed-origins목록에 배포 환경 도메인(http://ipiece.store,https://ipiece.store)을 추가했습니다.http://localhost:3000http://localhost:3000, http://ipiece.store, https://ipiece.storeCI/CD 트리거 추가 (
backend-cicd.yml)feat/#164)에서 변경 사항이 정상적으로 빌드 및 배포되는지 확인하기 위해 워크플로우 트리거에 브랜치를 추가했습니다.✅ PR 포인트
101 Switching Protocols상태 코드가 뜨며 즉시 연결되는지 확인이 필요합니다.🔗 관련 이슈
Closes #164