apicache
apicache copied to clipboard
Cross-Origin Request Blocked
When using apicache and the page it's cached, I start to get the follow error and can't access my page anymore. This only when I publish to Heroku (production), local it's working.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://mywebsite.... (Reason: missing token ‘authorization’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel).
apicache.options({
debug: false,
redisClient: redis.createClient({ url: 'redis://...' }),
});
const cache = apicache.middleware;
app.use(cache('25 minutes'));
cors: {
origin: ['https://mywebsite....'],
},
What could I be doing wrong?
"apicache": "^1.5.2",
"cors": "^2.8.5",
"routing-controllers": "^0.8.0",
"redis": "^2.8.0",
https://github.com/kwhitley/apicache/issues/92
Same issue here when caching with apicache and CORS: only the first request (which misses the cache) has the right answer headers. As soon as the request hits the cache, there are no CORS headers and the browser (or client application) refuses to read the content.
Same Issue here
Adding access-control-allow-origin (in lowercase) to headerBlacklist in the global options seems to solve the problem.