vue-realworld-example-app
vue-realworld-example-app copied to clipboard
307 redirect is not handled
Greetings. I would like to fix it myself, but I don't know where to start.
My backend responds on /api/users
with 307 redirect to /api/users/
(slash in the end). However this frontend doesn't handle that redirect.
When I patch sources to query /api/users/
, backend responds with 200 and all good.
Can you point what has to be changed to handle 307 redirects?
I met this issue too. But it seems axios has no power to parse the response header(check this), so we cannot handle the redirect response as we cannot get the header and don't kown it's a redirect. My workaround is that use Nginx as a reverse-proxy server, I think Nginx can handle this redirect stuff well.
Hi, I am also facing the issue while redirecting the api response 302.
One time its passed for 302 which have the another redirect URl. And then its creating the cross issue. The code I used to resolve one 302 from API is. Adding the proxy in package.json file.
"proxy":"https://localhost" (based on BE running locally in eclipse )
After doing this I have add the axios inceptor to check the response to redirect manually. But I am getting the error without any response or body.
api.interceptors.response.use((res) => {
window.location ="hello2"
console.log(">>>>>>>>>>>>",res);
}, (error) => {
if(error?.response?.status === 302){
console.log(">>>>>>>>>>>>",error);
window.location ="hello"
}
console.log(">>>>>>>>>>>>",error);
});