1
0
Fork 0

changed session cookie name to "__session". (Fixed login not working on production)

This commit is contained in:
Kim, Jimin 2021-09-14 18:02:03 +09:00
parent 70dda7f895
commit e9aaaa5ece
2 changed files with 11 additions and 1 deletions

View file

@ -22,15 +22,23 @@ admin.initializeApp({
const sessionOption: SessionOptions = {
secret: secret.session,
name: "__session", // https://stackoverflow.com/a/44935288/12979111
resave: false,
saveUninitialized: false,
cookie: {
maxAge: 1000 * 60 * 60 * 24 * 7, // 1 week
},
}
const app = express()
if (process.env.FUNCTIONS_EMULATOR !== "true") {
app.set("trust proxy", 1)
sessionOption.cookie = { secure: true }
sessionOption.cookie = {
...sessionOption.cookie,
sameSite: "none",
secure: true,
}
}
app.use(

View file

@ -16,6 +16,8 @@ export default (app: Express): void => {
config.pathPrefix + "/user-data",
checkIfLoggedIn,
async (req, res) => {
res.setHeader("Cache-Control", "private")
req.user
? res.status(200).send(req.user)
: res.status(500).send("Failed to get user")