I'm not sure why or exactly what is happening, but when I update from 0.1.9 to 0.2.0 this code has no effect:
import axios from 'axios'
axios.defaults.xsrfHeaderName = 'X-CSRF-TOKEN'
All of my requests fail due to the header being set to the default X-XSRF-TOKEN (X instead of C)
When I look in node_modules/@inertiajs/inertia I see there is a node_modules folder with it's own copy of Axios which is what I assume to be the issue, it's like there are two different Axios modules, one that Inertia is using and one that my code is using.
I'm not sure why or exactly what is happening, but when I update from
0.1.9to0.2.0this code has no effect:import axios from 'axios' axios.defaults.xsrfHeaderName = 'X-CSRF-TOKEN'All of my requests fail due to the header being set to the default
X-XSRF-TOKEN(Xinstead ofC)When I look in
node_modules/@inertiajs/inertiaI see there is a node_modules folder with it's own copy of Axios which is what I assume to be the issue, it's like there are two different Axios modules, one that Inertia is using and one that my code is using.
Hey @snaptopixel !
The header is set to X-XSRF-TOKEN by default. Check your Cross Site Request Forgery middleware to make sure that you're checking the correct header.
The Inertia.js docs have previously - incorrectly - said that the header value in question was X-CSRF-TOKEN, but it has since been amended.
Source: Axios header value
Thanks for the info! It's still a real issue though, I'm setting a custom value in axios.defaults which works fine in 0.1.9 but not 0.2.0, i haven't tested yet but I assume this would also affect any other overrides/defaults as well...
@snaptopixel Any update on this issue? What version of Axios does your project require?
Hi @reinink we're still pinned at 0.1.9 I haven't tried to update since this issue
@snaptopixel Understood. What version of Axios is your project using?
I stumbled upon this issue as well and it seems to be a packaging issue:
I updated my project to latest Axios v0.20.0. But because Inertia still depends on ^0.19.0, Yarn installs both versions into my project: My app code uses v0.20, but Inertia uses v0.19. Changing the Axios defaults within my app does affect v0.20, which Inertia doesn't use - so the changed defaults are not in effect.
From my point of view it's not recommended to update an Inertia project to Axios v0.20 yet. Maybe Inertia should update (or relax) its Axios dependency.
Yeah, okay, that makes sense.
Maybe Inertia should update (or relax) its Axios dependency.
What does that look like? Can you do this with NPM/yarn?
"axios": "^0.19.0|^0.2.0"
And would that actually help?
I'm not sure how this can be defined. So far I understand the docs, the syntax is:
"axios": "^0.19.0 || ^0.20.0"
BTW: The latest Axios is v0.20.0, not v0.2.0.
Hmm, now I am confused.
I would have expected the ^0.19.0 requirement to include 0.20.0? 馃
As a Ruby developer, this looks strange to me, too. But I found this:
Caret Ranges
Allow changes that do not modify the first non-zero digit in the version, either the 3 in 3.1.4 or the 4 in 0.4.2
https://classic.yarnpkg.com/en/docs/dependency-versions/#toc-caret-ranges
Yeah, okay, that makes sense.
I'm tempted to just update to ^0.19.0 || ^0.20.0.
However...
From my point of view it's not recommended to update an Inertia project to Axios v0.20 yet. Maybe Inertia should update (or relax) its Axios dependency.
Why do you recommend not upgrading yet?
Why do you recommend not upgrading yet?
I said this because you will then have two versions of Axios in the application at the same time (as described above). If Inertia.js is available with a relaxed dependency, I see no reason not to update Axios for the application.
Right, so you agree with the change to ^0.19.0 || ^0.20.0, yes?
Yes, this looks fine to me.
Done: https://github.com/inertiajs/inertia/releases/tag/v0.3.2 馃憤
Hopefully this helps, and hopefully [email protected] doesn't come out soon. 馃槄
Thanks @reinink, I've updated all deps and it LGTM! @ledermann you continue to be my hero 馃槈
Awesome, thanks for the update! 馃憤
We're having fun now. 馃槅
I was reading this thread, and a friend asked what comedian i was listening too.
Done (again): https://github.com/inertiajs/inertia/releases/tag/v0.8.1
Most helpful comment
https://github.com/axios/axios/releases/tag/v0.21.0 馃槅