在瀏覽器中打開(kāi)http://localhost:3000之后就一直在轉(zhuǎn),不顯示任何信息,求解答,謝謝大家var express = require('express');var app = express();var cookieParser = require('cookie-parser');app.use(cookieParser);app.get('/',function (req,res){ // 如果請(qǐng)求中的 cookie 存在 isVisit, 則輸出 cookie // 否則,設(shè)置 cookie 字段 isVisit, 并設(shè)置過(guò)期時(shí)間為1分鐘 if (req.cookies.isVisit) { console.log(req.cookies); res.send("再次歡迎訪問(wèn)"); } else { res.cookie('isVisit', 1, {maxAge: 60 * 1000}); res.send("歡迎第一次訪問(wèn)"); } res.send('Hello');});var server = app.listen(3000,function(){ var host = server.address().address; var port = server.address().port; console.log('The App running at://%s:%s',host,port);});
關(guān)于Express的cookie-parser
慕姐4208626
2018-09-04 09:14:19