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

/webhook relative link not working to serve GET #2

Open
LeeWarnock opened this issue Jul 26, 2017 · 0 comments
Open

/webhook relative link not working to serve GET #2

LeeWarnock opened this issue Jul 26, 2017 · 0 comments

Comments

@LeeWarnock
Copy link

LeeWarnock commented Jul 26, 2017

Could not verify webhook with Facebook, getting a 404 error with the file structure in Master: Cannot GET /

I copied your file structure, but had to change line 22 to start serving webhook,js, changing '/webhook' to '/' I think because webhook is in root and my relative link was wrong when I copied the Master branch code. I'm on a windows machine.

My working code:

/* For Facebook Validation */
//Replace the'/' below with proper relative link or absolute link if serving fron the internet
app.get('/', (req, res) => {
  if (req.query['hub.mode'] && req.query['hub.verify_token'] === 'tuxedo_cat') {
    res.status(200).send(req.query['hub.challenge']);
  } else {
    res.status(403).end();
  }
});

/* Handling all messenges */
//Replace the'/' below with proper relative link or absolute link if serving fron the internet
app.post('/', (req, res) => {
  console.log(req.body);
  if (req.body.object === 'page') {
    req.body.entry.forEach((entry) => {
      entry.messaging.forEach((event) => {
        if (event.message && event.message.text) {
          sendMessage(event);
        }
      });
    });
    res.status(200).end();
  }
});
@LeeWarnock LeeWarnock changed the title /webhook relative link not working so serve GET /webhook relative link not working to serve GET Jul 26, 2017
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

1 participant