Skip to content

POST / PATCH Method result in redirection on root app (/) #4616

Closed Answered by erwanclx
erwanclx asked this question in Help
Discussion options

You must be logged in to vote

A good night's sleep and the AdonisJS Discord will have given me a new perspective.
My issue, which isn't an issue, came from "Shield", with the CSRF protection. By default in the web kit, it is activated on the following methods: POST, PUT, PATCH, DELETE. However, with a Postman request I didn't include any CSRF tokens...

So I came up with two solutions:

  • Disable CSRF on POST / PATCH method by editing the following array in config/shield.ts (a bit radical) :
methods: ['POST', 'PUT', 'PATCH', 'DELETE'],
  • Disable protection on some of the endpoints in config/shield.ts (which meets my need).
    For example here, all my endpoints beginning with "api" are exclude from CSRF protection.
csrf: {

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RomainLanz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant