CORS preflight response doesn't match actual response
I solved my problem.
The issue is that Apollo Server adds CORS middleware by default, which was overriding my CORS settings. From Apollo's documentation:
Provide false to remove CORS middleware entirely, or true to use yourmiddleware's default configuration.
The default value is true.
To solve the issue, I simply had to disable CORS functionality in Apollo, which simply required setting cors: false
in .applyMiddleware like so:
server.applyMiddleware({ app, path: '/', cors: false,});
Further reference:
I had similar issues with apache2 proxy running in front of my Express services. The proxy was caching some (only some!) of the responses. This is what I added to the apache config and it solved the problem:
Header set Cache-Control "no-cache, must-revalidate" env=no-cache-headersHeader set Pragma "no-cache" env=no-cache-headersHeader set Expires "Sat, 1 Jan 2000 00:00:00 GMT" env=no-cache-headers