Node version: 20.10.0
Sails version (sails): 1.5.8
ORM hook version (sails-hook-orm): 4.0.0
Sockets hook version (sails-hook-sockets):2.0.0
Grunt hook version (sails-hook-grunt): 5.0.0
Uploads hook version (sails-hook-uploads): 0.4.3
DB adapter & version :sails-mongo@2.0.1
Hello, i'm having a problem with the CSRF configuration, the requests always hits the HTTP 403 forbidden response. Thanks in advance!
Following the docs, i set the route to get the crsf token to this:
'GET /csrfToken': { action: 'security/grant-csrf-token' }
And the cors configuration to:
cors: {
allRoutes: true,
allowCredentials: true,
allowOrigins: ['http://127.0.0.1:3000', 'http://localhost:3000'],
allowRequestHeaders: 'content-type,x-csrf-token,authorization',
allowRequestMethods: 'GET,POST,PUT,DELETE,OPTIONS,PATCH'
},
csrf: true,
I am able to acess the crsf token in the url http://localhost:1337/csrfToken
The request to the api are being made like this:
const request = await fetch(http://localhost:1337/api/v1/my-endpoint`, {
method: 'POST',
credentials:"same-origin",
headers: {
'X-CSRF-Token': csrfToken,
'Content-Type': 'application/json',
"authorization" : `Bearer ${sessionValues.token}`,
},
body:
JSON.stringify({
_csrf: csrfToken,
})
});
Node version: 20.10.0
Sails version (sails): 1.5.8
ORM hook version (sails-hook-orm): 4.0.0
Sockets hook version (sails-hook-sockets):2.0.0
Grunt hook version (sails-hook-grunt): 5.0.0
Uploads hook version (sails-hook-uploads): 0.4.3
DB adapter & version :sails-mongo@2.0.1
Hello, i'm having a problem with the CSRF configuration, the requests always hits the HTTP 403 forbidden response. Thanks in advance!
Following the docs, i set the route to get the crsf token to this:
'GET /csrfToken': { action: 'security/grant-csrf-token' }And the cors configuration to:
I am able to acess the crsf token in the url http://localhost:1337/csrfToken
The request to the api are being made like this: