mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 06:58:46 +00:00
암호 키 유무에 따른 자동 리다이렉션 구현
This commit is contained in:
@@ -9,8 +9,7 @@ export const init: ServerInit = () => {
|
||||
};
|
||||
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
const path = event.url.pathname;
|
||||
if (path.startsWith("/api") || path.startsWith("/auth")) {
|
||||
if (["/api", "/auth"].some((path) => event.url.pathname.startsWith(path))) {
|
||||
return await resolve(event);
|
||||
}
|
||||
|
||||
@@ -18,6 +17,9 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||
if (accessToken) {
|
||||
return await resolve(event);
|
||||
} else {
|
||||
redirect(302, "/auth/login?redirect=" + encodeURIComponent(path));
|
||||
redirect(
|
||||
302,
|
||||
"/auth/login?redirect=" + encodeURIComponent(event.url.pathname + event.url.search),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user