E:\nodetest>node server.js_http_outgoing.js:360 throw new TypeError('The header content contains invalid characters'); ^TypeError: The header content contains invalid characters at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:360:11) at E:\nodetest\node_modules\express-static\index.js:48:11 at FSReqWrap.oncomplete (fs.js:123:15)这个错误是什么原因?求大神指教源码:const express=require('express');const static=require('express-static');const cookieParser=require('cookie-parser');const cookieSession=require('cookie-session');const bodyParser=require('body-parser');const multer=require('multer');const consolidate=require('consolidate');const mysql=require('mysql');//连接池const db=mysql.createPool({host: 'localhost', user: 'root', password: 'yue638', database: 'blog'});var server=express();server.listen(8080);//1.解析cookieserver.use(cookieParser('sdfasl43kjoifguokn4lkhoifo4k3'));//2.使用sessionvar arr=[];for(var i=0;i<100000;i++){ arr.push('keys_'+Math.random());}server.use(cookieSession({name: 'zns_sess_id', keys: arr, maxAge: 20*3600*1000}));//3.post数据server.use(bodyParser.urlencoded({extended: false}));server.use(multer({dest: './www/upload'}).any());//4.配置模板引擎//输出什么东西server.set('view engine', 'html');//模板文件放在哪儿server.set('views', './template');//哪种模板引擎server.engine('html', consolidate.ejs);//接收用户请求server.get('/', (req, res)=>{ //查询banner的东西 db.query("SELECT * FROM banner_table", (err, data)=>{ if(err){ console.log(err); res.status(500).send('database error').end(); }else{ console.log(data); res.render('index.ejs', {banners: data}); } });});//4.static数据server.use(static('./www'));
添加回答
举报
0/150
提交
取消