You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
pizza.krasnikov.pro/.history/pages/api/sessions_20220525200049.js

24 lines
739 B

import { withIronSessionApiRoute } from "iron-session/next";
const VALID_EMAIL = "chris@decimal.fm";
const VALID_PASSWORD = "opensesame";
export default withIronSessionApiRoute(
async function loginRoute(req, res) {
// get user from database then:
req.session.user = {
id: 230,
admin: true,
};
await req.session.save();
res.send({ ok: true });
},
{
cookieName: "myapp_cookiename",
password: "complex_password_at_least_32_characters_long",
// secure: true should be used in production (HTTPS) but can't be used in development (HTTP)
cookieOptions: {
secure: process.env.NODE_ENV === "production",
},
},
);