编程语言
首页 > 编程语言> > 解决 Node 服务器返回结果的中文出现乱码

解决 Node 服务器返回结果的中文出现乱码

作者:互联网

通过设置 responseContent-type 来解决

import type { IncomingMessage, ServerResponse } from 'http'

(req: IncomingMessage, res: ServerResponse) => {
  // 省略 ...
  res.setHeader('Content-type', 'application/json;charset=utf-8')
  // 省略 ...
}

标签:Node,Content,...,res,IncomingMessage,乱码,服务器返回,ServerResponse,type
来源: https://www.cnblogs.com/yinyuxing/p/15787204.html