Open thany opened 1 year ago
Hi @thany ! First, thank you for reporting this. Second, a bit of bad news and some context. Updating axios to latest version unfortunately breaks the react app due to this bug: https://github.com/facebook/create-react-app/issues/11889 Regardless, we'll address the issue one way or another: either update axios after react-scripts is updated (hopefully soon), or replace axios usage in package with fetch, to avoid conflicts.
And last, but not least, there are some workarounds you could use. While not an official fix, I hope they can help. 1) AxiosDataFetcher is only used in Styleguide-Tracking component. If it's not something your nextjs app uses, you can remove lib/data-fetcher and your app should work fine after. 2) You could bring AxiosDataFetcher into the app remove the import from base package. Version upgrade requires some changes to it, however, this is what it would look like when using v1.x: https://github.com/Sitecore/jss/blob/feature/axios-upgrade/packages/sitecore-jss/src/axios-fetcher.ts This should help avoid version conflicts too.
I have also tried to override the depedency in package.json, from memory I went like this:
"overrides": {
"axios": "$axios"
}
It worked fine. But strangely this also proves that updating axios can be done without errors, or compiling it with this override in place would undoubtedly reproduce your error. Perhaps because CRA is not a part of a Next.js app, iirc.
Can you please look into this because of: An issue discovered in Axios 0.8.1 through 1.5.1 inadvertently reveals the confidential XSRF-TOKEN stored in cookies by including it in the HTTP header X-XSRF-TOKEN for every request made to any host allowing attackers to view sensitive information.
Newer versions of axios would also address the following Security findings:
+1 to upgrade axios
Description
The types returned from
AxiosDataFetcher::fetch()
from@sitecore-jss/sitecore-jss-nextjs
is incompatible with the actual type declared inaxios
. This happens after updating Axios to the latest version.Please note that the code runs fine, but won't perform a production build because of a typing error.
JSS returns this type:
Whereas an up-to-date Axios package expects a different, incompatible one:
It bares noting that putting overrides in package.json might work, but doesn't in our case, for some reason. A little bit like this:
Should work, but doesn't.
Expected behavior
No error, and an up-to-date Axios subdependency in sitecore-jss-nextjs.
Steps To Reproduce
data-fetcher.ts
Possible Fix
Please update Axios in
@sitecore-jss/sitecore-jss-nextjs
at your earliest convenience.Your Environment
Screenshots