javascript - Browser downloads the html file instead of opening -
i have created server node.js express open html file in public folder.
app.use(express.static(__dirname + '/public')); app.listen(8080);
i have done before without problems. in project when try open server in 127.0.0.1:8080
automatically downloads index.html file. tried different browsers result same.
update
open html file in edge. very slow processing thing. , got stuck when send request server.
i tried opening html file separately browser works without problem.
and tried giving html file location, result same.
i not know exact problem here. got know has content type td-lambda mentioned in comments. found solution this.
var express = require('express'); var app = express(); var server = app.listen(8080); app.set({ 'content-type': 'text/html' }); app.use(express.static(__dirname + '/public'));
and solved problem.
Comments
Post a Comment