feat: custom error page
This commit is contained in:
@@ -15,16 +15,13 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const path = getRequestURL(event).pathname;
|
||||
|
||||
const link = await db.query.links.findFirst({
|
||||
let link = await db.query.links.findFirst({
|
||||
where: eq(tables.links.path, path),
|
||||
});
|
||||
|
||||
if (!link) {
|
||||
throw createError({ statusCode: 404, message: "Not found" });
|
||||
}
|
||||
|
||||
if (link.disabled) {
|
||||
throw createError({ statusCode: 410, message: "This link has been disabled" });
|
||||
if (!link || link.disabled) {
|
||||
event.context.redirectNotFound = true;
|
||||
return;
|
||||
}
|
||||
|
||||
return sendRedirect(event, link.url, 302);
|
||||
|
||||
Reference in New Issue
Block a user