This is a simple react memory game app which i'm trying to run on apache. The app runs fine but when i copy the invite link produced and paste it in a newtab it gives error saying "'the requested url was not found on this server". It runs fine when i run it using "npm start" from the terminal but not on apache. This is my first day with apache so bear with me if the question is silly
Asked
Active
Viewed 496 times
1 Answers
1
Have you configured a reverse proxy in your Apache server? Because this is required for Apache to know how to handle URLs dynamically generated by React.
Example (from this answer):
<VirtualHost *:80>
ServerName yourdomain.com
ProxyPreserveHost on
ProxyPass / http://localhost:8080/
</VirtualHost>
If you don't want to meddle with your Apache setup your only option is to use a HashRouter component, so all URLs will be preceeded by a #
, this way your application's entrypoint is always its base URL and the routing in decided by React from the hash paremeter.
Examples:
<HashRouter
basename={optionalString}
getUserConfirmation={optionalFunc}
hashType={optionalString}
>
<App />
</HashRouter>
<HashRouter basename="/calendar"/>
<Link to="/today"/> // renders <a href="#/calendar/today">

Telmo Trooper
- 4,993
- 1
- 30
- 35