You will need to configure Apache to redirect all non-api URLs to the index.html (?) page where React Router can handle the routing. You will need to be able to access and edit the .htaccess file on the cPanel host to achieve this.
Laravel and React on shared hosting without Laravel Mix
Hi, I have this situation:
- 1 shared hosting with cPanel
- 1 laravel project
- 1 react project
The two react / laravel projects are separate and no laravel mix is used.
The problem arises when I try to access a url other than the main domain because I receive a 404.
Example:
-
If i type mysite[dot]com the react app loads without problems and then the react routing works without problems. So I can get to mysite[dot]com/user/profile
-
If i type mysite[dot]com/user/profile from browser the react project is not loaded but the request is handled by laravel and i receive 404 not found.
My goal is to be able to enable laravel routing only on routes starting with / api and for the rest to be managed by react. It's possible?
Thank you
Please or to participate in this conversation.