Question

I´m trying to get nowjs to work with expressjs 3.0alpha4. I´ve added the script to my view like so:

<script src="/nowjs/now.js"></script>

And have also tried:

<script src="https://localhost/nowjs/now.js"></script>

But all i get is a:

GET https://localhost/nowjs/now.js 403 (Forbidden)

Have anyone gotten this to work with expressjs 3.0.?

Even if i host the now.js file, I still get: Now is not defined

Était-ce utile?

La solution

You need to pass an HTTPServer object to the now initializer. Express 3.0 doesn't reveal this object like 2.x did.

So do something like:

var server = http.createServer(app).listen(app.get('port'), function() {
  console.log('Express server listening on port ' + app.get('port'));
}

var everyone = require('now').initialize(server);

Autres conseils

First check if you have your static middleware setup.

app.use( express.static(__dirname + '/public' ) )

Second make sure you put your nowjs directory inside the public directory with the now.js file inside the nowjs directory.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top