Skip to content

fix: 피드 CORS 커스텀 정책으로 교체 — no-cache 요청 시 CORS 헤더 누락 해결 - #41

Open
serithemage wants to merge 1 commit into
mainfrom
fix/dashboard-feed-cors
Open

serithemage wants to merge 1 commit into
mainfrom
fix/dashboard-feed-cors

Conversation

@serithemage

Copy link
Copy Markdown
Contributor

문제

https://spot.roboco.io 대시보드에서 Failed to load data.json: TypeError: Failed to fetch가 발생했다. Chrome 콘솔에는 No 'Access-Control-Allow-Origin' header가 찍혔다.

원인

관리형 응답 헤더 정책 CORS-AllowAllOrigins를 쓰면, 요청에 Cache-Control: no-cache가 있을 때 CloudFront 응답에서 access-control-allow-origin이 빠졌다(curl로 재현). 대시보드의 fetch(..., {cache:'no-store'})가 이 헤더를 보낸다. 기존 CloudFront 대시보드는 같은 출처에서 요청해서 CORS 검사가 없었기 때문에 이 문제가 드러나지 않았다.

변경

  • 수집기 스택: 커스텀 ResponseHeadersPolicy(허용 출처 *, originOverride: true)로 교체
  • assets/dashboard/index.html: cache:'no-store' 제거. 신선도는 1분마다 바뀌는 ?t= 쿼리로 확보한다.

검증 (2026-10-12, 수집기 스택은 이 브랜치로 이미 배포됨)

  • Origin + Cache-Control: no-cache 요청 → 200 + access-control-allow-origin: *
  • headless Chrome으로 https://spot.roboco.io 렌더링 → CORS 오류 0건, 데이터 로드 확인
  • 기존 URL /, /index.html → https://spot.roboco.io로 301 (PR feat: 대시보드를 GitHub Pages(spot.roboco.io)로 이전 #40 리다이렉트 반영)
  • npm test, npm run build 통과

🤖 Generated with Claude Code

spot.roboco.io 대시보드에서 data.json fetch가 CORS로 차단됐다. 관리형
CORS-AllowAllOrigins 정책은 요청에 Cache-Control: no-cache가 있으면
access-control-allow-origin을 붙이지 않았고, fetch의 cache:'no-store'가
이 헤더를 보낸다.

- 피드 CloudFront: 커스텀 ResponseHeadersPolicy(origin *, originOverride)
- index.html: cache:'no-store' 제거 (신선도는 분 단위 ?t= 쿼리로 확보)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@codesolarlght codesolarlght Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔆 CodeSolar review ✅ Looks good

대시보드 feed fetch 시 CloudFront 관리형 CORS 정책이 no-cache 요청에서 헤더를 누락하는 문제를 해결하기 위해, 커스텀 ResponseHeadersPolicy(originOverride: true)로 교체하고 대시보드 측에서 cache:'no-store'를 제거한 PR. 변경은 정확하며 테스트도 적절히 업데이트됨.

✅ No issues worth flagging.


solar-pro4 (openrouter) · 3 files · +29/-5 · 117.9s · CodeSolar

Comment /codesolar on this PR to re-run the review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant