How can I fix nginx to run my react website?

15 Views Asked by At

I am using an nginx VPS hosted on Hostinger and I have a NextJS app already being hosted, which is working great. If I ssh into my server and head to localhost:3000, I am able to access the site locally as well. However, I have created a new project, where the front end is a basic react app, and the backend is built using flask running in a docker container. When trying to get my react app setup, I followed all the steps. I created a config file in my sites-available, I linked it to the sites-enabled and I created a build of the project. I have attached my code for my config below so you can understand what I'm trying to do. Any help would be great (I'm new to nginx).

server {
    listen 80;
    server_name pitch-it.app;
    root /var/www/pitch-it/client/build;

    error_log  /var/log/nginx/pitchit-frontend.log warn;

    location / {
        proxy_pass http://localhost:5000;  # Path to your React app's build directory
        try_files $uri /index.html;  # Serve index.html for any unknown paths
    }
}
0

There are 0 best solutions below