Search code examples
node.jsrestify

Html page not opening in node js


I've got a button in my index.html file which when clicked should open another html page called index2.html in the root directory. However, when I click on the button I get a webpage not found option. What am I doing wrong?

app.js

server.get('/', restify.serveStatic({
 directory: __dirname,
 default: '/index.html'
}));

server.get('/page2', restify.serveStatic({
 directory: __dirname,
 default: 'index2.html'
}));

index.html

<a href="/page2"> <button type="button"> Full Chat history </button>  </a>

Solution

  • Your code here..

    server.get('/page2', restify.serveStatic({
     directory: __dirname,
     default: 'index2.html'
    }));
    

    Should be

    server.get('/page2', restify.serveStatic({
     directory:  __dirname,
     file: 'index2.html'
    }));