0

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.

Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
  • [_**Here**_](http://stackoverflow.com/questions/14095347/node-js-public-static-folder-to-serve-js-with-utf-8-charset) a link how to manage it, but it doesnt use the _express.static_ middleware you can define your own middleware for it. –  Nov 18 '15 at 19:18

1 Answers1

-5

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.

Rashad Ibrahimov
  • 3,279
  • 2
  • 18
  • 39