Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mxy2316868975javascript opened this issue Jan 8, 2024 · 9 comments

Comments

@mxy2316868975javascript
Copy link

本地hosts文件配置
127.0.0.1 localhost

现象
image
image

@avwo
Copy link
Owner

avwo commented Jan 8, 2024

看下响应内容是什么

@mxy2316868975javascript
Copy link
Author

看下响应内容是什么

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

@avwo
Copy link
Owner

avwo commented Jan 9, 2024

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

@mxy2316868975javascript
Copy link
Author

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

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

@avwo
Copy link
Owner

avwo commented Jan 9, 2024

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

@mxy2316868975javascript
Copy link
Author

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

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

@avwo
Copy link
Owner

avwo commented Jan 9, 2024

看下 devServer 的 allowedHosts 配置

@mxy2316868975javascript
Copy link
Author

devServer 的 allowedHosts

allowedHosts: 'all'

@avwo
Copy link
Owner

avwo commented Jan 9, 2024

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

@avwo avwo closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants