vue-realworld-example-app icon indicating copy to clipboard operation
vue-realworld-example-app copied to clipboard

307 redirect is not handled

Open danbst opened this issue 5 years ago • 2 comments

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?

danbst avatar Dec 04 '19 07:12 danbst

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.

pwli0755 avatar Mar 21 '20 09:03 pwli0755

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);
 });

ankitacroit09 avatar Nov 29 '21 08:11 ankitacroit09