Currently, I am developing a NodeJS application and have encountered an issue with a div element that has a background-image set in an external CSS file. Surprisingly, the CSS file functions perfectly when tested independently, and the background image displays correctly when viewing the HTML without Node.
The CSS code snippet:
#schoolInfo {
display: block;
background-image: url('slide1pic.jpg');
background-repeat: no-repeat;
width: 100%;
height: 100%;
background-size: cover;
}
Snippet from app.js:
var express = require('express');
var app = express();
var serv = require('http').Server(app);
var io = require('socket.io')(serv);
var path = require('path');
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.use(express.static('client/home'));
app.post('/createSchool', function(req, res) {
app.use(express.static('client/school'));
res.sendFile(path.join(__dirname, '/client/school/index.html'));
io.emit('updateSchool', response);
});
serv.listen(3000);
console.log("Server started on localhost://3000");
Even though the URL is absolute, it appears that Express cannot locate it. Oddly enough, there are no errors reported in the Command Prompt (where the server is executed) or in the browser console.
Is there something missing in my app.js file? Any insights or assistance would be highly appreciated.