Replies: 2 comments 4 replies
-
All worked is ideal.
further axios works by itself |
Beta Was this translation helpful? Give feedback.
2 replies
-
Can you please open a PR for same? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It's not a bug, so I didn't open a bug report on adonisjs/shield repo; I'm doing it because I think the maintainer can focus on real bugs instead of looking at a "unimportant" thing like that. I'm not a experienced developer and I'm just developing a hobby project. Sorry if I'm posting on the wrong section though.
That being said, I read that axios set and send cookies automatically when
withCredentials: true
, but I was struggling to make things work out even with everything well configured. Every time I tried to POST/GET a route protected with CSRF, I got an error saying that it was an invalid token. After a time, I discovered that the cookie was not being sent. Turns out that Adonis sets a cookie namedxsrf-token
and so axios can't get the cookie.I think axios is case sensitive and its default value for
xsrfCookieName
isXSRF-TOKEN
(accordingly to axios's documentation), hence axios was not sending the cookie.Consequently, to things work out, I had to set
xsrfCookieName: 'xsrf-token'
in axios instance. Then, everything works as expected.Like I said: it's not a bug, but a change like this I think can help people that is starting with Adonis and I think they'll struggle with that too if they are using axios.
Beta Was this translation helpful? Give feedback.
All reactions