update merge dan set cookies

This commit is contained in:
ari
2025-11-21 15:57:09 +07:00
parent fd8385650c
commit 87121d00fd
2 changed files with 20 additions and 5 deletions
+16 -1
View File
@@ -2,7 +2,6 @@ import { getRequestURL, readBody, setCookie } from 'h3'
// Function to verify JWT token with the userinfo endpoint
export default defineEventHandler(async (event) => {
console.log("=================== MASUK FE SSO! ===================")
const body = await readBody(event)
const url = getRequestURL(event)
const config = useRuntimeConfig()
@@ -40,6 +39,22 @@ export default defineEventHandler(async (event) => {
},
})
if (resp.status === 200) {
const data = await resp.json()
if (data?.data?.accessToken) {
setCookie(event, 'authentication', data.data.accessToken, {
path: '/',
httpOnly: true,
sameSite: 'strict',
maxAge: 60 * 60 * 24,
})
delete data.data.accessToken
return data
}
}
return new Response(await resp.text(), {
status: resp.status,
headers: {