如何使用快速会话节点js设置cookie?

时间:2018-08-20 14:26:37

标签: javascript node.js express cookies

我的客户端代码正在运行“ http://localhost:3000”,而我的节点服务器正在“ http://localhost:5000”上运行 查看我的服务器代码

https://repl.it/repls/ThunderousWeightyPdf

当我运行server时,它会在“ http://localhost:5000”上设置cookie,但是我想在正在运行的客户端上设置cookie。 “ http://localhost:3000”。我要在此处“ http://localhost:3000”上设置cookie

const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');

const morgan = require('morgan');
const cors = require('cors');
const session = require('express-session');


const app = express();



// Middleware
app.use(bodyParser.urlencoded({extended: false}))
app.use(bodyParser.json());
app.use(morgan('dev'));
app.use(cookieParser());
app.use(cors());

app.use(session({
    secret: 'asdassadsazz',
    resave: true,
    saveUninitialized: true
   // cookie: { secure: true }
}));



//Routes



module.exports = app;

0 个答案:

没有答案