Open
Description
While completing the test suite of my CORS middleware library, I ran into an interesting case. The section entitled CORS protocol and HTTP caches says the following:
[...] if
Access-Control-Allow-Origin
is set to*
or a static origin for a particular resource, then configure the server to always sendAccess-Control-Allow-Origin
in responses for the resource — for non-CORS requests as well as CORS requests — and do not useVary
.
However, in the case of a resource that
- systematically includes
Access-Control-Allow-Origin: https://example.com
in all responses, - omits the
Vary
header (as explained above), but - happens to allow credentials,
shouldn't responses to non-CORS requests also contain Access-Control-Allow-Credentials: true
? Otherwise,
- a response to a non-CORS request lacking that header could get cached, and
- that cached response could subsequently get served for credentialed CORS requests from
https://example.com
.
This situation would unduly cause the CORS check to fail (at step 8). Unless I'm missing something, perhaps this consideration deserves a mention in the standard.