I’m managing one kind of client request starts from ‘/js/’ which means root folder on server side or maybe will be located in ‘/public/js/’ for further use.
Okay, the problem is I got this message:
//server side
GET /js/socket.io/socket.io.js 304 7ms
// client side
Uncaught ReferenceError: require is not defined
Uncaught ReferenceError: io is not defined
[x] source
// index.html
<script src="/js/socket.io/socket.io.js"></script>
// app.js
app.get('/js/*', function (req, res) {
res.sendfile(__dirname + req.url.substr('/js'.length));
});
But it does work when I change to fixed path.
[o] source
// index.html
<script src="/socket.io/socket.io.js"></script>
// app.js
app.get('/socket.io/socket.io.js', function (req, res) {
res.sendfile(__dirname + '/socket.io/socket.io.js');
});
It’s kind of weird, isn’t it? Could anybody figure out where is wrong plz.
Thanks a lot.
What’s your exact problem with that response?
A
304status code meansNot modified, meaning that your browser can used the cached version of/js/socket.io/socket.io.jsinstead of the server having to send it to the browser again (therefore, saving bandwidth).