Combined fixes (#116)

* fix: missing CheckIcon import in LanguageSelector

* fix: #114 and error handling

* fix: #97

* fix: lint

* feat: #104

* fix: #72
This commit is contained in:
DecDuck
2025-06-10 10:08:01 +10:00
committed by GitHub
parent 60abc03091
commit 1bfdd73e4c
10 changed files with 53 additions and 47 deletions

View File

@ -1,27 +0,0 @@
import { H3Error } from "h3";
import sessionHandler from "../internal/session";
export default defineNitroPlugin((nitro) => {
nitro.hooks.hook("error", async (error, { event }) => {
if (!event) return;
// Don't handle for API routes
if (event.path.startsWith("/api")) return;
if (event.path.startsWith("/auth")) return;
// Make sure it's a web error
if (!(error instanceof H3Error)) return;
switch (error.statusCode) {
case 401:
case 403: {
const user = await sessionHandler.getSession(event);
if (user) break;
return sendRedirect(
event,
`/auth/signin?redirect=${encodeURIComponent(event.path)}`,
);
}
}
});
});