I have two apps, api and frontend, I have uploaded in the same droplet, the frontend app is running on the port 3000 and the api is running on the 8000, my nginx config is:
{.....
# root /var/www/html;
root /home/testing-client/dist;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_pass http://localhost:3000;
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;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
}
....
but in my frontend app throw error to connect with api in localhost:8000
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!
the steps that I followed were:
root /home/CompleteTestGit/dist;
location / { proxy_pass http://localhost:3000; # First attempt to serve request as file, then # # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; }
my client app on port 3000 is working but no get data of the api on port 8000
Yes it is possible. Have you checked whether the API end is listening on port 8000 from inside the server?
try: telnet localhost 8000
You might need to install telnet (yum install telnet or apt-get install telnet). You also want to check the API’s error log for potential issues.
This comment has been deleted
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.