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

CORS origin custom function throw and crash the app #4530

Closed
ludohenin opened this issue Jan 28, 2020 · 0 comments · Fixed by #4532
Closed

CORS origin custom function throw and crash the app #4530

ludohenin opened this issue Jan 28, 2020 · 0 comments · Fixed by #4532
Assignees
Labels

Comments

@ludohenin
Copy link
Contributor

Steps to reproduce

Setting the origin to a custom function make the app crash if an error is passed to the callback function.

corsConfig.origin = function customOrigin(origin, callback) {
  if (whitelist.indexOf(origin) !== -1) {
    callback(null, true);
  } else {
    callback(new HttpErrors.Forbidden('Not allowed by CORS'));
  }
};

Current Behavior

/home/ludohen/github/ta-api-core-2/node_modules/@loopback/rest/dist/rest.server.js:616
            throw err;

Expected Behavior

send a response with the correct error code.

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

Successfully merging a pull request may close this issue.

2 participants