whatwg / fetch

Fetch Standard
https://fetch.spec.whatwg.org/
Other
2.11k stars 330 forks source link

Should credentialed, same-site, cross-origin requests be easier to enable? #1226

Open colinclerk opened 3 years ago

colinclerk commented 3 years ago

The Fetch standards currently disallow using Access-Control-Allow-Origin: * with Access-Control-Allow-Credentials: true

This policy requires developers to take an extra step when enabling credentials on same-site but cross-origin fetch requests. Instead of using a * wildcard, they must explicitly return the origin they are allowing.

Today, browsers are defaulting cookies to SameSite=Lax, which takes priority over CORS. Even with credentials: "include" and CORS properly configured, a cookie set to SameSite=Lax won't be included with the cross-origin request.

So, I believe a case can be made that disallowing Access-Control-Allow-Origin: * with Access-Control-Allow-Credentials: true is a redundant protection.

Some potential options:

annevk commented 3 years ago

I think a same-site value could be reasonable for Access-Control-Allow-Origin. In some sense that is duplicative of a request in #890 that thus far hasn't gained traction, but it's more narrowly scoped so let's see what people think.