How to deploy angular front and nodeJS back on same droplet using nginx

Posted October 15, 2020 3.8k views

Hello and thank you for your help.

I have created droplet on which I want to setup my project. I have managed to set up front (Angular/Nginx) and back (NodeJS) following this tutorial>

Back is working and properly connecting to my db and sending data that I can access when I type http://<server-api>:3000. Front is also working (I can access it on http://<server-api>) but not receiving data from the backend. I have tried to find a solution to the problem I have added reversed proxy to my default nginx file.

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                proxy_pass http://localhost:3000;
                proxy_cache_bypass $http_upgrade;


but when I add this I can’t reach http://<server-api>:3000 anymore.
General problem is I don’t understand how to connect front and back. Any help or instructions or what to look for next to understand problem would be welcome. Thank you!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Have you checked your cros configuration on your node application?
origin: ’*’, //replace this with your domain name
optionsSuccessStatus: 200,
methods: “GET, PUT, DELETE”