Tuesday 6 June 2017

Why CSS and Bootstrap elements disappear with node express server?

I firstly made a basic node server like this:

  var connect = require('connect');

  var serveStatic = require('serve-static');
  connect().use(serveStatic(__dirname)).listen(8080, function() {
    console.log('Server running on 8080...');
  });

Then I replaced it with an express server like this:

       var express = require("express");
       var app     = express();
       var path    = require("path");

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

       app.listen(8080);
       console.log("Running at Port 8080");

With the first one, everything worked fine. CSS, JQuery, images etc..., but with the second one, some of my style elements totally disappeared and it can't reach the pictures on the site. What did I miss? How can I solve it?



via JustMatthew

No comments:

Post a Comment