SockJS multiplexing example 404 index.html not found

SockJS multiplexing example 404 index.html not found

Problem

Looking at SockJS multiplex example

I got the server running. When I go to http://127.0.0.1:9999/multiplex I see a welcome message “Welcome to SockJS!

When I try to browser to index.hmtl http://127.0.0.1:9999/index.html I get 404 message “Cannot GET /index.html

The ‘index.html‘ is in the same directory as the server.js is running. Why can’t the server find this file?

Problem courtesy of: dev.e.loper

Solution

Installed express 3.1.1 and made some code updates to server.js. Now when I go to http://127.0.0.1:9999/ it serves me index.html as specified in server:

app.get('/', function (req, res) {
    res.sendfile(__dirname + '/index.html');
});

Not sure why but http://127.0.0.1:9999/index.html still doesn’t give me the file.

Solution courtesy of: dev.e.loper

Discussion

Leave a Reply

Your email address will not be published. Required fields are marked *