Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

403 when posting in postman using Yeoman's Angular-Fullstack

I am trying to populate a local db using MongoDB in my Yeoman Angular-fullstack application. I used the endpoint command:

yo angular-fullstack:endpoint [options] <name>

and can get to the route, but it is an empty object. It will not allow me to post.

I am getting the error: Connect 403 Error: CSRF token missing

Mongod is running fine.

There is authentication on the page, but at this point no forbidden routes.

Thank you for your hellp.

like image 910
Tess O'Brien Avatar asked Dec 10 '22 18:12

Tess O'Brien


2 Answers

Go to your .\server\config\express.js and either change xssProtection to false or add an 'development' !== env to the if statement:

if ('test' !== env && 'development' !== env) { // <- add development env here
    console.log("using lusca");

    app.use(lusca({
      csrf: {
        angular: true
      },
      xframe: 'SAMEORIGIN',
      hsts: {
        maxAge: 31536000, //1 year, in seconds
        includeSubDomains: true,
        preload: true
      },
      xssProtection: true // <- or change this to false
    }));
  }
like image 60
White Noise Avatar answered Feb 09 '23 00:02

White Noise


or comment these lines located in \server\config\express.js

 csrf: {
        angular: true
      },
like image 21
Jesus Rodriguez Avatar answered Feb 08 '23 23:02

Jesus Rodriguez