The node js server is not loading my website files

后端 未结 2 998
鱼传尺愫
鱼传尺愫 2020-12-21 15:41

When I run node index.js the browser loads only the html, disregarding javascript, images, and css , and if I try to access a link it shows a blank plage: node.js Cannot GET

相关标签:
2条回答
  • 2020-12-21 16:35

    You need show the error with your question and "/login.html" file?

    Or quick-fix, you can change your code as below:

    res.sendFile(__dirname + '/index.html', {});
    

    to

    res.render('index.html', { /*data*/ });
    
    0 讨论(0)
  • 2020-12-21 16:41

    Here you have some code to tell your server what to when when the browser requests /.

    app.get('/'
    

    You haven't written anything to tell it what to do when the browser requests /login.html. Write something for that case.

    0 讨论(0)
提交回复
热议问题