Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If-modified-since and If-none-match headers may break Nuxt when using axios #557

Open
fago opened this issue Jan 12, 2022 · 1 comment · May be fixed by #558
Open

If-modified-since and If-none-match headers may break Nuxt when using axios #557

fago opened this issue Jan 12, 2022 · 1 comment · May be fixed by #558

Comments

@fago
Copy link

fago commented Jan 12, 2022

By default nuxt-axios is proxying headers when doing requests. This is a very handy feature but becomes dangerous when If-modified-since or If-none-match headers are present.

We had the severe issue of google search console reporting repeated 503 errors, but those were not reproducable. After logs of investigation we were able to determine what happened via the logs: Sometime the google bot sent a "if-modified-since" header, what gets proxied, so the backend correctly responded with an (empty) 304 response. Axios by default handles 304 status as ok and tries to process the response as normal. Since it's empty it fails and errors out with error 500.

Unfortunately, nuxt cannot handle 304 responses since it does not have the cached previous response. Instead, axios should not forward the If-modified-since and If-none-match headers (since axios does not have the cache, that would be correct).

We were able to fix this by add the headers to https://axios.nuxtjs.org/options#proxyheadersignore - unfortunately one has to repeat all the other headers being ignored by the default when settings this option. That's not ideal for maintenance (as this shows, this is a critical setting to have correct), but that's a different issue.

Long story short, I think proxying If-modified-since and If-none-match headers does not make sense in general and those should be included by default in https://axios.nuxtjs.org/options#proxyheadersignore

@davision
Copy link

davision commented Feb 4, 2022

Any news on resolving PR for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants