Answer the question
In order to leave comments, you need to log in
How to return a picture (stupid question)?
I'm probably doing it very stupidly, but, having abandoned Apache, I began to transfer my assets using fs, with the following code:
app.get('/assets/css/index.css', function(req, res) {
fs.readFile('/var/www/assets/css/index.css', function(err, data) {
res.end(data);
});
});
app.get('/sources/exit.svg', function(req, res) {
fs.readFile('/var/www/sources/exit.svg', function(err, data) {
res.end(data);
});
});
Answer the question
In order to leave comments, you need to log in
Don't reinvent the wheel, use express.static()
And it doesn't work most likely because of the wrong (or even missing) Content-Type header
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question