今天在看百度统计数据时候发现有一篇文章是从谷歌搜索过来的 随手点开 发现页面报错
TypeError: The header content contains invalid characters
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:358:11)
at ServerResponse.res.setHeader (/test/hexo/node_modules/connect-auth/node_modules/connect/lib/patch.js:58:22)
at /test/hexo/node_modules/hexo-server/lib/middlewares/route.js:27:11
at call (/test/hexo/node_modules/connect/index.js:239:7)
at next (/test/hexo/node_modules/connect/index.js:183:5)
at /test/hexo/node_modules/hexo-server/lib/middlewares/header.js:9:5
at call (/test/hexo/node_modules/connect/index.js:239:7)
at next (/test/hexo/node_modules/connect/index.js:183:5)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
发现
http://www.opscaff.com/2017/02/05packetfence结合AD域做有线dot1.x认证 #不能打开
http://www.opscaff.com/2017/02/05packetfence结合AD域做有线dot1.x认证/ #可以打开
按照网上的一些教程修改了path.js部分关于Header的代码以后发现仍旧报错,打开node_modules/hexo-server/lib/middlewares/route.js
代码发现报错的第27行有SetHeader代码 发现是重定向的url有中文未做encode随即修改代码解决
#res.setHeader('Location', root + url + '/');
res.setHeader('Location', root + encodeURIComponent(url) + '/');