CORS 헤더 생성기
주요 웹 서버와 프레임워크용 CORS 설정을 생성합니다.
와일드카드 오리진(*)은 Access-Control-Allow-Credentials: true와 함께 사용할 수 없습니다.
Access-Control-Allow-Methods
클라이언트 JavaScript에 노출할 쉼표로 구분된 응답 헤더 목록입니다.
프리플라이트(Preflight) 캐시 유지 시간(초 단위, 기본값 86400).
HTTP 응답 헤더
Nginx Location 스니펫
location /api/ {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' 'https://example.com';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';
add_header 'Access-Control-Max-Age' 86400;
add_header 'Content-Type' 'text/plain; charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
add_header 'Access-Control-Allow-Origin' 'https://example.com' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
}