Building and hosting a react app on shared hosting

25 Views Asked by At

If there is anyone of you familiar with strapi react full stack or actually any other stack (ofc you are ) but are you familiar with hosting backend on a server then react app on shared hosting ( Premium hosting from hostinger ) I have some weird problem when I use npm run build then uploading the static files to the hosting it somehow changes my API URL endpoint from a HTTP to HTTPS and it is causing problems nothing works I'm saving it in my .env I tried

"start:staging": "env-cmd -f .env.staging react-scripts start",
"start:prod": "env-cmd -f .env.production react-scripts start",
"build:prod": "env-cmd -f .env.production react-scripts build",
"build:staging": "env-cmd -f .env.staging npm run build"

ofc with building 2 more .env.production and .env.staging and nothing is wrong with the server it self because in my local version it works just fine with the correct HTTP request (my server is a strapi app hosted on VPS directly using IP address that's why it doesn't have SSL certificate and I can't afford one or a domaine to use the free SSL)

any type of solution I've been trying and looking so hard for like 8 hours straight

0

There are 0 best solutions below