遇到一个非常诡异的问题,还请各位大佬指点
在阿里云服务器上用 pm2 部署了一个 node 项目。 本地的一个 vue 代码直接去访问这个 api.xxx.xxxx 的接口可以正常访问通。
但是用 postman 去访问这个接口的时候,访问不通,postman 页面:Could not get response
这是什么原因,有遇到过相同问题的吗?
遇到一个非常诡异的问题,还请各位大佬指点
在阿里云服务器上用 pm2 部署了一个 node 项目。 本地的一个 vue 代码直接去访问这个 api.xxx.xxxx 的接口可以正常访问通。
但是用 postman 去访问这个接口的时候,访问不通,postman 页面:Could not get response
这是什么原因,有遇到过相同问题的吗?
|
FaustYAug 6, 2024
1
条件太少了,可能代理问题、或者 postman 请求拼的不对吧
|
|
FaustYAug 6, 2024
2
可以用 postman 你有问题的请求,生成一个 fetch 的代码,去你 Vue 的页面下执行一下,看看是不是报错,报错了大概率 postman 请求拼的不对。
|
|
DolovAug 6, 2024
3
有没有可能是 vue 项目,中配置的 proxy 把请求路径转化了
|
|
4
@Dolov 还是很诡异,浏览器直接输入 api.xxxx 这个接口地址是有返回的,本地项目也可以直接访问,就是在 postman 中就没有响应,我的 ngxin 配置和 ssl 配置都是新的,难道是因为 ssl 原因吗
|
|
6
我用 apifox 去访问这个接口也是可以通的,就 postman 不可以。。。
|
|
catinsidesAug 6, 2024
7
都转成 curl 命令对比一下
|
|
airycanonAug 6, 2024
8
Postman 有没有关闭 SSL certificate verification ?
|
|
10
@catinsides 用 curl 在服务器上执行返回是正确的,本地命令后执行,
curl -v POST https://api.xxx/login \ -H "Content-Type: application/json" \ -d '{"username":"test", "password":"test"}' 直接返回了这个错误 * Could not resolve host: POST * Closing connection curl: (6) Could not resolve host: POST * Host api.yxdjjz.cn:443 was resolved. * IPv6: (none) * IPv4: 47.95.68.15 * Trying 47.95.68.15:443... * Connected to api.yxdjjz.cn (47.95.68.15) port 443 * ALPN: curl offers h2,http/1.1 * (304) (OUT), TLS handshake, Client hello (1): * CAfile: /etc/ssl/cert.pem * CApath: none * Recv failure: Connection reset by peer * LibreSSL/3.3.6: error:02FFF036:system library:func(4095):Connection reset by peer * Closing connection curl: (35) Recv failure: Connection reset by peer |
|
11
@catinsides 本地浏览器和本地项目都是可行的,curl 本地命令后就出现这个问题了
|
|
12
突然想到,ssl 证书是申请的个人免费版本,难道跟这个有关系?
|
|
siweipanccAug 6, 2024 via iPhone
13
更新下客户端证书
|
|
14
@siweipancc postman 里面添加个人证书吗?直接是关闭证书校验了,我觉得是我配置的有问题,但是又能访问,,,
|
|
ikAug 6, 2024 via iPhone
16
POST 这个参数删掉应该也成
|
|
amleeAug 6, 2024
17
curl -v -k -X POST https://api.xxx/login \
-H "Content-Type: application/json" \ -d '{"username":"test", "password":"test"}' |
|
siweipanccAug 6, 2024
18
你用北京阿里云没做备案? powershell7 执行下代码可以更直观看到原因
`Invoke-WebRequest -Method GET -Uri http://api.yxdjjz.cn/login -SkipHttpErrorCheck -OutFile res.html && Invoke-Item res.html` |
|
19
@siweipancc 好像就是因为域名没备案的原因 感谢感谢🙏
|
|
githmbAug 7, 2024
20
以为是 Bug ,结果是天朝的 Feature (
|