feat: add environment configuration and implement cookie handling for user authentication

This commit is contained in:
Ardeman
2025-02-27 19:37:31 +08:00
parent 9386b8dd69
commit f9d861f24d
15 changed files with 213 additions and 30 deletions
+12 -2
View File
@@ -1,10 +1,20 @@
import { USER_COOKIES } from '~/configs/storages'
import { ADMIN_COOKIES, USER_COOKIES } from '~/configs/cookies'
export const setUserLogoutHeaders = () => {
const responseHeaders = new Headers()
responseHeaders.append(
'Set-Cookie',
`${USER_COOKIES.token}=; Path=/news; Max-Age=0`,
`${USER_COOKIES.token}=; Path=/news; HttpOnly; SameSite=Strict; Max-Age=0`,
)
return responseHeaders
}
export const setAdminLogoutHeaders = () => {
const responseHeaders = new Headers()
responseHeaders.append(
'Set-Cookie',
`${ADMIN_COOKIES.token}=; Path=/admin; HttpOnly; SameSite=Strict; Max-Age=0`,
)
return responseHeaders