-
Hi, is there any possibility to attach csrf token when making http post test request ? I'm getting actually invalid csrf token response from server. I just found solution to test it against current env like csrf: {
enable: Env.get('NODE_ENV') === 'testing' ? false : true
.....
} Its right way ? Here is my code: trait('Test/ApiClient');
test('some test', async({client}) => {
const response = await client
.post('/request')
.attach('excel_file', Helpers.tmpPath('../test/excel_file.xlsx'))
.end();
) Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
crbast
Jul 24, 2020
Replies: 1 comment
-
hi @mortenko 👋 I think you can just disable CSRF for testing
Yep Get CSRF token in controllers :request.csrfToken source : https://forum.adonisjs.com/t/how-to-access-csrf-token-from-controller/698 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mortenko
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi @mortenko 👋
I think you can just disable CSRF for testing
Yep
Get CSRF token in controllers :
source : https://forum.adonisjs.com/t/how-to-access-csrf-token-from-controller/698