404 Error reaching Node.js server on page "nodejs / health / check"

I am using the nodejs module on the Drupal 7 website. Here is the message I get in the log on random pages:

Message Error reached on Node.js server in "nodejs / health / check": [404] Not found.

Tried restarting Nodejs, but it seems to be already running. So why this error?

+4
source share
2 answers

How to restart the node server. From the terminal where you start the server, you will get a stack trace. or if it returns an error, you can simply see it on the screen of your browser where the request came from.

- , Linux Osx, - . Stack trace in browser window

. . , . -, js routes.js, :

var express = require('express');
var router = express.Router();`
router.post('/user/', controllers.users.create); //This is a route 

node, app.js

:

router.<method>('<route>',<function(req, res, next){}> ) ;

, , "nodejs/health/check" , api: :

router.get('nodejs/health/check', checkHealth(req, res){
 console.log("output something");
 res.send("Outputed Something")
} ) ; 

  • router - -.

  • checkHealth - , , .

+2

, . , - :

var router = express.Router();

router.get('/nodejs/health/check', function(req, res, next){
    res.render('theHTMLPage', {foo:bar}); //in the {}, you will be passing params the html page might need if it using a template engine
})

router.get('/nodejs/health/check', function(req, res, next){
    res.send('Whatever you want to send back');
})

res.render node URL- {} res.send , : " "

+1

All Articles