How does Express or node.js automatically serve javascript files?

I added this line to the index.jade file:

script(src="/socket.io/socket.io.js") 

And somehow, he automatically knew how to maintain this Javascript file for my client. How it works?

+4
source share
1 answer

Socket.io adds a request handler to the server. Cm:

https://github.com/learnboost/socket.io/blob/master/lib/manager.js#L90

The handler deals with any requests starting with /socket.io and processes them (for example, it serves the socket.io.js file from any place where the module is installed)

+6
source

All Articles