403 when posting to a postman using Yeoman Angular-Fullstack

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

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

and can get on the route, but this is an empty object. This will not allow me to post.

I get an error:   Connection error 403: CSRF token is missing

Mongod is working fine.

The page has authentication, but there are currently no prohibited routes.

Thanks for your hell.

+4
source share
2 answers

. \server\config\express.js xssProtection false, 'development'! == env if:

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
    }));
  }
+11

, \server\config\express.js

 csrf: {
        angular: true
      },
+2

Source: https://habr.com/ru/post/1626950/


All Articles