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

Use with koa-router #40

Closed
joegalley opened this issue Oct 22, 2017 · 1 comment
Closed

Use with koa-router #40

joegalley opened this issue Oct 22, 2017 · 1 comment

Comments

@joegalley
Copy link

I'm not sure how koa-csrf intercepts HTTP requests - does it matter if I set my koa-router middleware before or after setting koa-csrf?

This is what I'm using now:

server.use(new CSRF({
    invalidSessionSecretMessage: 'Invalid session secret',
    invalidSessionSecretStatusCode: 403,
    invalidTokenMessage: 'Invalid CSRF token',
    invalidTokenStatusCode: 403,
    excludedMethods: ['GET', 'HEAD', 'OPTIONS'],
    disableQuery: false
}));

server.use(router.routes());
@stephenmathieson
Copy link
Contributor

You should use koa-csrf before you define your routes. Generally speaking, global middleware should always be "first" in your stack.

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