Question

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

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!


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

anyone? :(