Set-cookie cannot write locally

problem description

cannot write to local after receiving set-cookie, domain is useless

http request is shown in figure

clipboard.png

clipboard.png

clipboard.png

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( ... ); 
} );


you are the backend interface requested by the frontend project (domain a) (domain b), set-cookies is the response of domain b, so cookies is set to domain b, while domain an is inaccessible.
in fact, you don't have to manage cookies,. Cookies will automatically take it with you the next time you request the interface. There is no need for you to manually manage set-cookies content in the front-end project


for security reasons, because the requested url is different from the source from which you want to set cookie (port is different).


the front end forgot to save qwq after setting cross-domain permissions.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c1dfe8-333ba.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c1dfe8-333ba.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?