You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
davision
added a commit
to davision/axios-module
that referenced
this issue
Jan 13, 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
The text was updated successfully, but these errors were encountered: