0

I am using window.location.href to route the page to an external link:

<Route exact path={rootUrl} component={() => { window.location.href =`https://${window.location.hostname}/www/testurl?google=true`; return null; }} />

But this code is throwing Cross-Site Scripting issue during FOD scan. Is there a cleaner way to do this ? Or is there a fix for it ?

Thanks for the help.

I referred this similar question but it didn't help: how to protect location.href from cross site scripting in javascript?

user2128
  • 443
  • 7
  • 26

1 Answers1

0

You could create a component and use react router elements.

<Route
  path="/your-path"
  component={ Redirect }
  loc="https://your-link"
  />

this seems cleaner compared to what you have . Also check this link for better understanding , i was able to research more on router links and found this on this platform. React-Router External link

if this helps you please mark it. Thank you