Skip to content
Advertisement

Deploying PERN stack on AWS issue

So I’m frustrated with this process I’ve watched the same tutorial a bunch on times https://www.reddit.com/r/reactjs/comments/jeuwvi/deploying_full_stack_app_on_ubuntuaws_postgres/.

Everything seems perfect but the frontend doesn’t seem to be making contact with the backend. Using xginx and pm2. In the config for the xginx my locations look like this

         location / {
                try_files $uri /index.html;
         }

         location /api {
            proxy_pass http://localhost:3001;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }

I’m not even sure if this is where the issue lies. I can hit my backend and database from insomnia to create a user and get a response back but when I do it from the actual site it sends the request to localhost3001 for some reason. I have environment variables set and all of that as well. It seems like each part are working separately fine but not together. Any suggestions? https://barn.bid/ Also this is the route from insomnia that made it so I could create a user ‘https://barn.bid/api/users’ (email,firstName,lastName,username,password) if you wish to see that working. Any thoughts as to what could fix the problem or suggestions would be GREATLY appreciated.

Advertisement

Answer

The .env makes the client side use the port 3001, which is same as the server side.

This leads to a conflict of port usage. Declare the port of client side. Check this out: Change Port Number

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement