How does the express framework get the interface? session, already exists in the interface. Session, writes the interface in express, but you can't call it when you put the project in express.

to make a website, you need to use single sign-on, the front end is built with vue-cli, and then use build to package the project and put it in express and forward it through express. But because single sign-on is successful, it will jump directly to my index.html, so I don"t know how to get the directory structure of token
express returned to me by the front-end page in the express route:

.

clipboard.png
index.htmlvue

loginindex
vue-cliindex.html:


oidc-client.jsjs
login.jsjs

login.js:


sessionsession Storageexpress:

clipboard.png

asked my colleagues at the lower back end. They said that webserver generally receives values by sending requests in the page. I wrote the following code

in the app.js of express.
app.post("/user/login", function(req, res) {
    res.status(200)
    res.json({ message: "Token" })
    console.log(req)
})

the code called in the login method in the project"s login.js is as follows:

function log() {

    Array.prototype.forEach.call(arguments, function(msg) {
        if (msg instanceof Error) {
            msg = "Error: " + msg.message;
        } else if (typeof msg !== "string") {
            msg = JSON.stringify(msg, null, 2);
        }
        console.log(msg)
        
        //sessionexpress
        var ajax = new XMLHttpRequest();
        ajax.setRequestHeader("Content-type", "application/json");
        ajax.open("post", "...");
        ajax.send(msg)
        console.log(ajax.status);
    });
}

but after running like this, single sign-on will not work, and the forwarding layer in the middle of express, has not been used for the first time. I would like to ask you to be familiar with the mistakes made by Daniel in express, or a better and more reasonable way to get the information in session Storage. Thank you

.
Sep.01,2021

1. You can try express's plug-in express-session
2. You can try using jwt in express


  1. you can put the session related to the user's session into the cookie, such as token, etc., and then you can get
  2. through req.cookies.token in the route of express.
  3. when the frontend requests, take the information that express wants in sessionStorage and put it in http header or the requested body, such as req.header.token or req.body.token .
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-1eab41e-2044.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-1eab41e-2044.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?