Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在API请求中未指定端口号的情况下,服务器如何确定此请求是针对端口80或443的_Api_Nginx_Server_Ip_Port - Fatal编程技术网

在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 / {

我在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,因此,我在该上下文中回答。

相对URL与当前页面URL相结合,以创建最终URL。因此,如果当前页面使用HTTPS,那么最终URL也将使用HTTPS。