无法设置由node.js发出的cookie

美好的一天! 有一个node.js服务器,授权后发送cookie。 服务器响应中包含“Set-Cookie”,但浏览器不接受它们。 请求服务器通过JQuery的AJAX发送。

服务器:

var express = require('express'), http = require('http'), app = express(), mysql = require('mysql'), cookie = require('cookie'); app.use(function (req, res, next) { res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, HEAD'); res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type, Authorization'); res.setHeader('Access-Control-Allow-Credentials', true); next(); }); app.post('/login', jsonParser, (request, response) => { if(!request.body) return response.sendStatus(400); var dbHandler = mysql.createPool({ database : config.get('db:database'), host : config.get('db:host'), user : config.get('db:user'), password : config.get('db:password'), insecureAuth: config.get('db:insecureAuth'), }); getUser(dbHandler, request.body.username, request.body.password, function(id){ getPlace(dbHandler, id, function(place){ getItems(dbHandler, place['id'], place['url'], function(items){ response.cookie('logined', true, { expires: new Date(Date.now() + 1000*60*60*24), domain:'localhost:8000/', httpOnly: true }); response.writeHead(200, {'Content-Type': 'text/html; charset=utf8'}); response.send('Ok'); }); }); }); }) app.listen(config.get('port'), () => { console.log('server is listening on', config.get('port')); }) 

截图 – 在浏览器中的响应 在这里输入图像说明