fix(coming-soon): let logged-in admins bypass the gate
Admins can now load the public site and their dashboard while coming-soon mode is on, instead of being redirected to /coming-soon for everything outside /admin/*.
This commit is contained in:
parent
84aea08a5f
commit
0927b66b4f
1 changed files with 9 additions and 0 deletions
|
|
@ -21,6 +21,15 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logged-in admins bypass coming-soon (and see the public site + their dashboard)
|
||||||
|
try {
|
||||||
|
const headers = import.meta.server ? useRequestHeaders(["cookie"]) : undefined;
|
||||||
|
const member = await $fetch("/api/auth/member", { headers });
|
||||||
|
if (member?.role === "admin") return;
|
||||||
|
} catch {
|
||||||
|
// Not authenticated — fall through to redirect
|
||||||
|
}
|
||||||
|
|
||||||
// Redirect all other routes to coming-soon
|
// Redirect all other routes to coming-soon
|
||||||
return navigateTo("/coming-soon");
|
return navigateTo("/coming-soon");
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue