1

This is the code i have used for redirection.

It is redirecting to

http://localhost:3000/something/https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies

instead of

https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies
<Link
  to={{
    pathname:
      "https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies"
  }}
  target="_blank"
>
  <Button variant="contained" className="py-1 px-2">
    <i className="ri-upload-2-line pe-2"></i> Apply
  </Button>
</Link>
keikai
  • 11,706
  • 7
  • 39
  • 59
Shelcia
  • 31
  • 3

3 Answers3

0

Next.js Link is designed to be used only as a internal routing tool, because it works with next.js router. For external link use standart anchor tag <a href...

Wraithy
  • 859
  • 3
  • 8
0

I think react-router attempt assuming relative path, if you want absolute link you can use directly tag a instead of Link component.

<a href="https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies" target="_blank">
  <Button
    variant="contained"
    className="py-1 px-2">
      <i className="ri-upload-2-line pe-2"></i> Apply
  </Button>
</a>
GABORIEAU
  • 31
  • 2
0

If you are using next/link you need to use Link as bellow

<Link
  href={"https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies"}
  passHref
>
  <Button variant="contained" className="py-1 px-2">
    <i className="ri-upload-2-line pe-2"></i> Apply
  </Button>
</Link>

And if you are using react-router-dom you can open external link like this

<Link to={{ pathname: "https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies" }} target="_blank" />
Ali Hussnain
  • 290
  • 3
  • 11