cookie now supports http and https

This commit is contained in:
suricatingss
2026-01-18 22:06:33 +00:00
parent 3efc733d4a
commit 1410dc84f6

View File

@@ -3,6 +3,9 @@ export default defineEventHandler(async (event) => {
const body = await readBody(event) const body = await readBody(event)
const is_https = await getRequestProtocol(event) == "https"
//console.log(is_https)
if ( !body.email || !body.password ) if ( !body.email || !body.password )
throw createError({ statusCode: 400, message: "Bad form. Use e-mail and password" }) throw createError({ statusCode: 400, message: "Bad form. Use e-mail and password" })
//console.log(body) //console.log(body)
@@ -32,6 +35,11 @@ export default defineEventHandler(async (event) => {
secure: { secure: {
user_id: body.id user_id: body.id
} }
}, {
cookie: {
secure: is_https,
sameSite: is_https ? 'none' : 'lax'
}
}) })
console.log(await getUserSession(event)) console.log(await getUserSession(event))