user9079075
user9079075

Reputation:

ngrok Cannot GET / local server up and running

I'm trying to follow Crowdbotics' Messenger bot tutorial, however. I did exactly as he mentioned but i am getting this.

My folder:

enter image description here

Okay so, first of all i run node index.js and get the following:

enter image description here

Right after that. We initialize our ngrok server by ngrok http 5000 and get the following:

enter image description here

But on EVERY http request i get the classic Cannot GET /.

On the hindsight, my index.js only contain:

const express = require("express");
const bodyParser = require("body-parser");

const app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.listen(5000, () => console.log('Webhook server is listening, port 5000'));

I can't really point out what i am doing wrong, your help is truly appreciated.

Upvotes: 1

Views: 2722

Answers (2)

Prisoner
Prisoner

Reputation: 50721

Your index.js has started a server that listens and respond to the HTTP protocol - but it does not "serve files" the same way a web server such as Apache does.

As @Yana notes, you need to explicitly set a route to do something, such as send a text response back.

If you want the favicon.ico file to be sent when requested, then you need to setup a static route for that as part of your index.js code.

Upvotes: 0

Yana Agun Siswanto
Yana Agun Siswanto

Reputation: 2032

Based on your express js code, I think you haven't define the routes to '/'

add this before the app.listen on the index.js file

app.get('/', (req, res) => res.send('Hello World!'))

Upvotes: 2

Related Questions