Core: Adonis Post Requests Always returns 403.

Created on 17 Aug 2017  路  4Comments  路  Source: adonisjs/core

Structuring The Issue

This issue about Routing. Because while I was trying to make post requests, I get errors.

Brief Description

While I was trying to make post requests in AdonisJS, I get error. For example

localhost:3333/phones => requests came from directly post, ajax or postman after request I got 403 error.

Sample Code

Router

const Route = use('Route')

Route.get('/', 'HomeController.index');
Route.post('phones', 'PhoneController.store');

Controller

'use strict'

class PhoneController {

  * store(request, response) {
    console.log("...")
  }

}

Error Stack (if any)

Only output: 403

There is no any other output about error.

Screenshots (if any)

There is no any other screenshot about this error.

Most helpful comment

Ok. I solved :) When I'm looking for config files I found shield.js files.

If I use like this it works

csrf: {
    enable: false,
    methods: ['POST', 'PUT', 'DELETE'],
    filterUris: [],
    compareHostAndOrigin: true
  }

All 4 comments

Ok. I solved :) When I'm looking for config files I found shield.js files.

If I use like this it works

csrf: {
    enable: false,
    methods: ['POST', 'PUT', 'DELETE'],
    filterUris: [],
    compareHostAndOrigin: true
  }

with this way you just close the csrf protection

For those still looking for this in the future. Drop a csrf field into your html form by using:
{{ csrfField() }}

The docs can be found in the security section here.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

codingphasedotcom picture codingphasedotcom  路  3Comments

devcaststudio picture devcaststudio  路  3Comments

amrayoub picture amrayoub  路  4Comments

itsg2jakhmola picture itsg2jakhmola  路  3Comments

imperez picture imperez  路  4Comments