I was researching the purpose of CORS headers, and the accepted answer here: What is the issue CORS is trying to solve? says, that the reason for its existence is, to prevent cookies unintentionally being sent to external sites when making HTTP requests from JS (fetch
or XMLHttpRequest
).
Reading up on how cookies are handled based on the Set-Cookie documentation page, doesn't the SameSite=Strict
cookie option obsolete CORS completely? It says:
means that the browser sends the cookie only for same-site requests, that is, requests originating from the same site that set the cookie. If a request originates from a different domain or scheme (even with the same domain), no cookies with the SameSite=Strict attribute are sent.
In summary both CORS headers and the SameSite=Strict
option for the Set-Cookie
header seem to solve the same problem. Why does both exist?