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

OPTIONS header doesn't work #2

Open
OmgImAlexis opened this issue Oct 13, 2017 · 3 comments
Open

OPTIONS header doesn't work #2

OmgImAlexis opened this issue Oct 13, 2017 · 3 comments

Comments

@OmgImAlexis
Copy link
Contributor

OmgImAlexis commented Oct 13, 2017

If you use router.allowedMethods() before koa404Handler you get a 404 returned for all OPTIONS requests. Maybe something needs to be added to the docs or something may need to be changed to allow it to work in any order.

I'd suggest just checking if the Allow header is set as that means it'll be an OPTIONS request.

// Mount the app's defined and nested routes
app.use(router.routes());

// 404 handler
app.use(koa404Handler);

// Options method
app.use(router.allowedMethods({
    throw: true,
    notImplemented: () => new Boom.notImplemented(),
    methodNotAllowed: () => new Boom.methodNotAllowed()
}));
@niftylettuce
Copy link
Contributor

can you add the failing test case to tests?

@OmgImAlexis
Copy link
Contributor Author

Added, if you move the 404handler above the router.allowedMethods like above it'll pass the test.

Ref: 3d4425a#diff-c1129c8b045390789fa8ff62f2c6b4a9R21

@niftylettuce
Copy link
Contributor

PR welcome

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