I am using Express to run simple HTTP server (all real communication goes over Socket.IO). I used this code:
var express = require('express');
var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(80);
app.use(express.static(__dirname));
Which runs server over current directory. My problem is that the encoding header is not sent. How can I set the default charset encoding? I'd like to avoid overriding some methods just because of that.
You should set a meta tag in head section of your html
<meta charset='utf-8'></meta>
If you need to set charset for every response, I recommend to use body-parser plugin for this purpose. It has default charset utf-8.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.