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

307 redirect is not handled #286

Open
danbst opened this issue Dec 4, 2019 · 2 comments
Open

307 redirect is not handled #286

danbst opened this issue Dec 4, 2019 · 2 comments

Comments

@danbst
Copy link

danbst commented Dec 4, 2019

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?

@pwli0755
Copy link

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.

@ankitacroit09
Copy link

ankitacroit09 commented Nov 29, 2021

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

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

No branches or pull requests

3 participants