【发布时间】:2021-07-19 18:25:00
【问题描述】:
我没有在我的 api 端点中提及端口号,但服务器如何决定使用端口 80 或 443 来处理此请求
const {data} = await axios.get('/api/users/currentuser');
【问题讨论】:
-
相对 URL 与当前页面 URL 组合以创建最终 URL。因此,如果当前页面使用 HTTPS,那么最终 URL 也将使用 HTTPS。
我没有在我的 api 端点中提及端口号,但服务器如何决定使用端口 80 或 443 来处理此请求
const {data} = await axios.get('/api/users/currentuser');
【问题讨论】:
在 NGINX 中使用类似的东西:
server {
root /var/www/html;
server_name _;
# this is the react/angular fronted application endpoints
location / {
try_files $uri $uri/ /index.html;
}
# this is the api endpoints
location /api {
proxy_pass http://127.0.0.1:8000;
}
}
但是,您没有在问题中明确提到您是否使用 NGINX,但是您在该问题的 5 个标签之一中有 nginx,所以我假设您必须使用 NGINX,所以,我正在回答那个上下文。
【讨论】: