//response header
OPTIONS <https://evanmoon.tistory.com/rss> 200 OK
Access-Control-Allow-Origin: <https://evanmoon.tistory.com>
Content-Encoding: gzip
Content-Length: 699
Content-Type: text/xml; charset=utf-8
Date: Sun, 24 May 2020 11:52:33 GMT
P3P: CP='ALL DSP COR MON LAW OUR LEG DEL'
Server: Apache
Vary: Accept-Encoding
X-UA-Compatible: IE=Edge
//error
Access to fetch at ‘<https://evanmoon.tistory.com/rss’> from origin ‘<https://evan-moon.github.io>’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: The ‘Access-Control-Allow-Origin’ header has a value ‘<http://evanmoon.tistory.com>’ that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
Simple Request
예비 요청 X
바로 본 요청
Credentialed Request
CORS의 기본 방식은 아니고, 다른 출처 간 통신에 보안을 강화하고 싶을 때 사용
Front는 요청에 credentials 설정을 포함하여 전송해야 한다.
credentials 설정을 포함하면, CORS 정책 위반 여부 검사에 두 가지 룰 추가
응답 헤더에는 반드시 Access-Control-Allow-Credentials: true가 존재해야 한다.
Access-Control-Allow-Credentials: true 면 Access-Control-Allow-Origin 에 * 을 사용할 수 없고, url이 명시되어야 한다.
credentials: 'include' 옵션의 의미
동일 출처 상관 없이 무조건 요청에 인증 정보가 포함되도록 설정
요청에는 브라우저의 쿠키 정보가 담겨있다.
구글 크롬 브라우저
credentials 기본값이 same-origin이기 때문에,
포트 3000에서 4000으로 보내는 리소스 요청에 쿠키는 담기지 않는다.
credentials: 'include' 설정해주면 다른 도메인이라도 쿠키 전송할 수 있다.