【发布时间】:2015-09-29 09:31:49
【问题描述】:
我注意到我所有带有 ü,ä,ö 的图像都无法在我的生产服务器上运行。使用 nodemon + browersync 在本地服务可以正常工作。
我必须进行哪些设置才能显示我的图像。
我在我的 HTML 头中使用 utf-8
<!doctype html>
<html class="no-js" ng-app="recipes">
<head>
<meta charset="utf-8">
我想我不必在我的 mongodb 中进行任何设置: How do I configure my MongoDB to take UTF-8 into account?
那么我猜只有 express 服务器 ("express": "^4.12.0",) 需要一些额外的配置?
图片在服务器上,名称为:
niveskocht-71-grüne-speckbohnen-auf-mandel-pak-choi.jpg
我的 chrome 控制台将我显示为路径:
http://my-website/assets/images/niveskocht-71-gr%C3%BCne-speckbohnen-auf-mandel-pak-choi.jpg
我在尝试加载图像时收到 404。
编辑: 我将此添加到我的 server.coffee 中:
app.use((req, res, next) ->
res.charset = "utf-8";
console.log parseurl(req).pathname
if (parseurl(req).pathname.indexOf('login') != -1 || req.session.userType)
next()
据此: Node.js public static folder to serve js with utf-8 charset
我得到一个 utf-8 标头:
这就是它在我的本地主机上的样子:
【问题讨论】: