Footnotes
-
Preflighted requests | MDN: “Unlike simple requests, for “preflighted” requests the browser first sends an HTTP request using the OPTIONS method to the resource on the other origin, in order to determine if the actual request is safe to send.“ ↩
-
CloudFront 배포의 캐시 동작이 HTTP 요청에 대한 OPTIONS 메서드를 허용함: “CloudFront는 기본적으로 GET 및 HEAD 메서드만 허용합니다.” ↩
CORS error 원인 찾기
| 언제 | 왜 |
|---|---|
Console·Network 에 CORS error |
preflight 에 Access-Control-Allow-Origin(ACAO) 이 없으면 브라우저는 5xx·404·타임아웃을 전부 CORS 로 뭉갠다1 |
preflight 가 server: awselb/2.0 의 5xx |
LB 가 직접 만든 응답이다 — 앱 응답이 아니니 CORS 헤더가 붙을 수 없다 |
preflight 의 status 와 server 헤더 둘로 가른다.
| preflight | server | ACAO | 갈래 | 원인 |
|---|---|---|---|---|
503 |
awselb/2.0 | 없음 | 인프라 | 등록된 target 02 — 서비스 다운·배포 실패·CrashLoop |
502 |
awselb/2.0 | 없음 | 인프라 | 타깃이 끊거나 잘못 응답 — 크래시·OOM·포트 불일치 |
504 |
awselb/2.0 | 없음 | 인프라 | LB idle timeout 초과 — 느린 쿼리·외부 연동 지연 |
404 |
앱 | 없음 | 경로 | path 오타, ingress rule 불일치 |
204·200 |
앱 | 없음 | CORS | CORS 미설정 |
204 |
앱 | 있음 | CORS | access-control-allow-headers 에 요청 헤더가 빠짐 |
204 |
앱 | * |
CORS | credentials: 'include' 와 * 는 병용 불가 — 오리진을 명시한다 |
204 |
앱 | 정상 | 정상 | CORS 아님. 본 요청의 본문·인증·에러를 본다 |
Footnotes
-
CORS errors — MDN: “For security reasons, specifics about what went wrong with a CORS request are not available to JavaScript code. All the code knows is that an error occurred.” ↩
-
ALB 트러블슈팅 — HTTP 503: “The target groups for the load balancer have no registered targets, or all of the registered targets are in an unused state.” 전부 unhealthy 면 503 이 아니라 그대로 보낸다 — health checks: “If a target group contains only unhealthy registered targets, the load balancer routes requests to all those targets, regardless of their health status.” ↩