Skip to content

Commit

Permalink
Preflight 요청에 헤더를 추가할 수 있을까?
Browse files Browse the repository at this point in the history
  • Loading branch information
genie-youn committed Mar 10, 2021
1 parent 6089dca commit 4f652b5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Browser/Preflight_요청에_헤더를_추가할_수_있을까.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@
해당 헤더는 Axios의 인터셉터를 통해 추가되도록 되어 있기 때문에 모든 요청에 포함되어 전달될것이라 기대했지만, Preflight 요청에는 추가되지 않았고 Preflight 요청은 헤더를 추가하는등의 제어를 할 수 없나? 하는 의구심이 들었다.

결론부터 얘기하자면 CORS-preflight fetch 는 온전히 브라우저가 제어하는 영역이므로 사용자가 별도의 헤더를 추가하는등의 행동을 할 수 없다.

https://fetch.spec.whatwg.org/#cors-preflight-fetch

*request* request가 주어지면, 다음과 같은 단계로 **CORS-preflight fetch** 가 이루어진다.

1. *preflight*
{
method: `OPTIONS`,
URL: *request* 의 current URL,
initiator: *request* 의 initiator,
destination: *request* 의 destination
}

0 comments on commit 4f652b5

Please sign in to comment.