Report this

What is the reason for this report?

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

Posted on October 15, 2020

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> https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04.

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!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

anyone? :(

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.