Answer the question
In order to leave comments, you need to log in
Why is node.js server not serving svg correctly?
Here is part of the code
let server = http.createServer((req, res) => {
if(req.url.match(/.svg$/)){
let data = fs.createReadStream(path.join(__dirname, 'public', req.url));
res.writeHead(200, {
'Conten-Type' : 'image/svg+xml'
})
data.pipe(res);
}else{
handleError(404, new Error('Страница не найдена'), res);
}
});
server.listen('4000', () => {console.log('Server run')});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question