Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header not set on error response #62

Open
cyclecycle opened this issue Jun 13, 2019 · 2 comments
Open

Header not set on error response #62

cyclecycle opened this issue Jun 13, 2019 · 2 comments

Comments

@cyclecycle
Copy link

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

@dead-horse
Copy link
Member

try opts.keepHeadersOnError = true, it will set headers to err.header if an error is thrown.

@cyclecycle
Copy link
Author

cyclecycle commented Jun 13, 2019

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);
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants