在API请求中未指定端口号的情况下,服务器如何确定此请求是针对端口80或443的
我在api端点中并没有提到端口号,但服务器是如何决定使用端口80或443来服务此请求的在API请求中未指定端口号的情况下,服务器如何确定此请求是针对端口80或443的,api,nginx,server,ip,port,Api,Nginx,Server,Ip,Port,我在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 / {
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,因此,我在该上下文中回答。相对URL与当前页面URL相结合,以创建最终URL。因此,如果当前页面使用HTTPS,那么最终URL也将使用HTTPS。