problem description
cannot write to local after receiving set-cookie, domain is useless
http request is shown in figure
Server code
var cookieParser = require( "cookie-parser" );
app.use( cookieParser() );
var allowCrossDomain = function( req, res, next ) {
res.header( "Access-Control-Allow-Origin", "*" );
res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("Access-Control-Allow-Credentials", "true");
res.header("X-Powered-By"," 3.2.1");
res.header("Content-Type", "application/json;charset=utf-8");
next();
};
app.use( allowCrossDomain );
app.get( "/login", async( req, res ) => {
// ...
var cookie_data = { username: username, password: password };
res.cookie( "userinfo", JSON.stringify( cookie_data ), { domain: "http://47.52.236.152", httpOnly: false } );
res.send( ... );
} );