![](/img/trans.png)
[英]When I try to connect to a localhost it starts printing out crazy outputs that I can't understand
[英]How can I connect localhost of the host machine?
我只是通过在 Nginx 中做反向代理来解决。
location / {
try_files $uri /index.html;
}
location /api {
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;
}
第一个位置 / 将找到静态前端文件, /api 将转到 localhost:3000。
例如,就我而言
this.url='https://yourdomain.com/api/' 访问后端。
也不要忘记所有后端路由都以“api/”开头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.