whistle icon indicating copy to clipboard operation
whistle copied to clipboard

代理localhost没问题,为什么代理127.0.0.1请求会504

Open mxy2316868975javascript opened this issue 1 year ago • 9 comments

本地hosts文件配置 127.0.0.1 localhost

现象 image image

mxy2316868975javascript avatar Jan 08 '24 09:01 mxy2316868975javascript

看下响应内容是什么

avwo avatar Jan 08 '24 09:01 avwo

看下响应内容是什么

没有响应内容一直pending,127.0.0.1换成localhost就,可以请问原因有哪些

mxy2316868975javascript avatar Jan 09 '24 03:01 mxy2316868975javascript

whistle 里面可以看到 127.0.0.1 的请求吗,再看下服务端有没有现在请求的域名

avwo avatar Jan 09 '24 05:01 avwo

whistle 里面可以看到 127.0.0.1 的请求吗,再看下服务端有没有现在请求的域名

whistle里可以看到请求,pending一段时间后显示504, 服务端有请求的域名

mxy2316868975javascript avatar Jan 09 '24 06:01 mxy2316868975javascript

规则里面的 127.0.0.1:3000 改成 http://localhost:3000 试试

avwo avatar Jan 09 '24 09:01 avwo

规则里面的 127.0.0.1:3000 改成 http://localhost:3000 试试

改成localhost没问题,想问的是用127.0.0.1为什么不行的原因,以及解决方案

mxy2316868975javascript avatar Jan 09 '24 12:01 mxy2316868975javascript

看下 devServer 的 allowedHosts 配置

avwo avatar Jan 09 '24 12:01 avwo

devServer 的 allowedHosts

allowedHosts: 'all'

mxy2316868975javascript avatar Jan 09 '24 12:01 mxy2316868975javascript

这个是你本地服务问题,你可以简单写个监听 3000 端口的服务测下是否ok

avwo avatar Jan 09 '24 14:01 avwo