Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.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
Javascript Webhook隧道未连接_Javascript_Node.js_Express_Webhooks_Contentful - Fatal编程技术网

Javascript Webhook隧道未连接

Javascript Webhook隧道未连接,javascript,node.js,express,webhooks,contentful,Javascript,Node.js,Express,Webhooks,Contentful,我已经创建了一个NextJS和Express应用程序。有一些简单的测试路由,如下所示: const server = express(); server.get('/api/test', (req, res) => { res.status(200).send({ message: 'test' }); }); server.listen(3000); 当我访问http://localhost:3000/api/test在浏览器中或作为Postman中的GET请求,我成功地在JS

我已经创建了一个NextJS和Express应用程序。有一些简单的测试路由,如下所示:

const server = express();

server.get('/api/test', (req, res) => {
  res.status(200).send({ message: 'test' });
});

server.listen(3000);
当我访问
http://localhost:3000/api/test
在浏览器中或作为Postman中的GET请求,我成功地在JSON对象中获取了测试消息

我现在已经从Contentful CMS设置了一个Webhook。为了在本地测试这一点,我使用了路由到上面URL的Ngrok。当我测试webhook时,Ngrok接受请求,但返回以下错误:

The connection to http://xxxxx.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:3000/api/test.

Make sure that a web service is running on localhost:3000/api/test and that it is a valid address.

The error encountered was: dial tcp: lookup tcp/3000/api/test: nodename nor servname provided, or not known
我不知道这里发生了什么。我的手动测试证明端点确实有效。为什么Ngrok不连接到它?作为第二次测试,我尝试使用Ultrahook代替Ngrok,但遇到了同样的问题

编辑:
Ngrok的主要错误是:
502坏网关

您是通过整个互联网呼叫
localhost
,还是Ngrok在您的本地网络中运行?Ngrok不关心客户端。如果没有客户端,我们可以运行ngrok.make request to xxx.ngrok.com/api/test@SagarRanaMagar当我向xxx.ngrok.com/api/test发出本地(浏览器/邮递员)或webhook请求时,我得到了上述错误。但是如果我直接转到
http://localhost:3000/api/test
端点工作。@Sv443我相信本地主机是我的机器特有的。您是通过整个internet调用
localhost
,还是Ngrok在您的本地网络中运行?Ngrok不关心客户端。如果没有客户端,我们可以运行ngrok.make request to xxx.ngrok.com/api/test@SagarRanaMagar当我向xxx.ngrok.com/api/test发出本地(浏览器/邮递员)或webhook请求时,我得到了上述错误。但是如果我直接转到
http://localhost:3000/api/test
端点可以工作。@Sv443我相信本地主机是特定于我的机器的