简体   繁体   中英

How to make axios url point in my VPS nginx

I deploy first time my app in a VPS with a new domain. Till now my project axios url was 'http://localhost:5000/posts' My node server is running in 5000 port and i use proxy in react to listen to5000 and not 3000.

So, how do i transfer thoses urls to my machine? do i have to use my new server IP or example.com domain to axios url?

I am able to understand that you want to have react and nginx application running on same server under same IP and you have react application running on 3000 port and nodejs on 5000.

You can have following configuration in your default.conf

server {
  root /var/www/html;
  
  server_name _;
  listen 3000;

# this is the react application endpoints
  location / {
    try_files $uri $uri/ /index.html;
  }
}

In your react application, use the api endpoint as http://127.0.0.1:5000/posts .
So now, react application will be dealt by NGINX and api by nodejs listening on 5000.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM