cors
cors copied to clipboard
Header not set on error response
Hi,
I have a situation where when I receive a response with an error status (in this case status 416), there are no CORS headers present on the response. It works fine with otherwise. Any idea why this could be?
Cheers,
Nick
try opts.keepHeadersOnError = true, it will set headers to err.header if an error is thrown.
Hi, thanks for the response. I had tried this, doesn't seem to make any difference. err.header is undefined.
I'm instantiating like this (using with sqlite-to-rest):
const corsOptions = {
origin: '*',
allowHeaders: 'range',
keepHeadersOnError: true,
}
getSqliteRouter({ dbPath })
.then(router => {
app.use(router.routes())
.use(router.allowedMethods())
.use(cors(corsOptions))
.listen(PORT);
});