0

I have a page in my application where backend decides where user should be redirected next. And it can be external link like 'google.com' or internal '/'. I use useNavigate hook from react-router-dom.

import { useNavigate } from "react-router-dom";
import axios from "axios";

useEffect(async () => {
  await axios.get().then((response) => {
    navigate(axios.redirectLink);
  });
});

It perfectly works for internal links, but doesn't work for navigate('https://google.com'). Then it tries to open https://my-website/https://google.com. What might be a solution here?

rel1x
  • 2,351
  • 4
  • 34
  • 62

1 Answers1

1

There is no solution in navigating if you want a use Link tag do that else you can check this link as well

React-Router open Link in new tab

<Link to="your url" target="_blank">Test</Link>
Meet Majevadiya
  • 355
  • 2
  • 8