I developed a react application and a node API that work together. My React application was built with vite.js and dropped on a hosting. The node server has been placed on a VPS server. Here is what was done:
- correctly configured github actions for CI/CD (React and Node)
- Settings of the htaccess file below
- configuration of the hosting DNS to point to the VPS server (the hosting of the react site built (dist / index html) and the VPS on now the same ip)
- apache configuration to set proxy redirects on domain address
When I access my site example.xyz I do not land on the index.html file in /dist/index.html present on the server but on the infinite loadpage.
I voluntarily deactivated the firewall so as not to add difficulty to the problems already encountered (ufw). my server does not have an SSL certificate, hence the http present in my configuration.
=> .htaccess
DirectoryIndex /dist/index.html
Redirect /assets/ /dist/assets/
RewriteEngine On
RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} !^([^@]*)@@https?://\1/.*
RewriteRule \.(gif|tif|pdf|wav|wmv|wma|avi|mov|mp4|m4v|mp3|zip|json|md|php?)$ - [F]
=>Apache config mywebsie.xyz.conf
<VirtualHost *:80>
ServerAdmin contact@mywebsie.xyz
ServerName mywebsie.xyz
ProxyPreserveHost On
ProxyPass / http://ip
ProxyPassReverse / http://ip
</VirtualHost>
Edit
My html (react build) is hosted on server xx.xx.xxx.198 and should be available at example.com. The html makes requests to my nodeJS API hosted on xxx.xx.xxx.215 at port 8005. I ran into this issue when pointing my DNS to that of the VPS. When I reset the DNS, I access my html fine with example.com. Now that the server xx.xx.xxx.198 (html) has its own IP and I can access the pages from the url (so problem partially solved) I can't check the TLS (SSL) for get HTTPS on the server xxx.xx.xxx.215 (API node) because the domain must point to it... It's a vicious circle... FYI, I want to keep the separation of front and back (so keep my API accessible via IP) because I plan to develop a ReactNative version which will have to make requests to this same server.
EndEdit
I would like to understand how to correctly configure a build of a react application placed on a hosting as well as an apache server so that the user can access the html/js pages generated by the build and that the requests are made to my API.
Take into consideration that I am a beginner and this is my first release. I voluntarily replaced my ip and my domain because the site, although inaccessible, may be vulnerable. However, if you are missing information, I will be very quick. Thank you very much to everyone who will help me.