-1

I have a React app where the start page needs to be a static html page created by the art team. The problem is that I can't get the Router to redirect from "/" to the static page

<Redirect from="/" to="/welcome/index.html" />

because it passes everything through the React index page (due to the single page application logic). I have tried to make a component with the static page's code in, but I keep getting a lot of errors which I don't know how to fix, as the static page contains a lot of <svg> tags that I am not familiar with (I could not have created this static page's functionality by myself). Is there any way to do a redirect bypassing React's single page logic?

  • `react-router` only manages pages the React app is rendering, internally. If you need to redirect to an external URL then use Javascript to do so, e.g. something like `window.location.href = "...."`. – Drew Reese Apr 04 '23 at 08:32
  • Or even use old school links in your JSX components like `click here`. You can keep the static page completely separate from the React project. – Kokodoko Apr 04 '23 at 08:39
  • I don't need to get there from a link. I need to make it so that when a user types the address mysite.com/, he is immediately redirected to mysite.com/welcome/index.html – Myrto Pirli Apr 04 '23 at 08:46
  • Take the value from user input. Then use window.location.href –  Apr 04 '23 at 08:57
  • @HimuraDaBattosuai I think he meant "typed in the browser's adress bar", not in the application itself. – N.K Apr 04 '23 at 09:24
  • @MyrtoPirli does that link answers your question ? https://stackoverflow.com/questions/50792942/how-to-import-html-file-into-react-component-and-use-it-as-a-component – N.K Apr 04 '23 at 09:25

1 Answers1

0

Found a solution. Made "/" redirect to a component called Welcome:

<Redirect from="/" to="/Welcome" />

and inside the Welcome component I put

export default function Welcome(){
  window.location.href = '/welcome/index.html';

  return(
    <>
    </>
  )
}