diff --git a/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx b/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx index 99d1a2584..95239919a 100644 --- a/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx +++ b/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx @@ -1,6 +1,6 @@ import type { Metadata } from "next"; import { Suspense } from "react"; -import { notFound } from "next/navigation"; +import { notFound, redirect } from "next/navigation"; import { TRPCError } from "@trpc/server"; // Placed here because gridstack styles are used for board content @@ -50,16 +50,24 @@ export const createBoardContentPage = >( page: async ({ params }: { params: Promise }) => { const resolvedParams = await params; const queryClient = getQueryClient(); + const session = await auth(); - const [board, session] = await Promise.all([ - getInitialBoard(resolvedParams).catch((error) => { - if (error instanceof TRPCError && (error.code === "NOT_FOUND" || error.code === "BAD_REQUEST")) { - notFound(); + const board = await getInitialBoard(resolvedParams).catch((error) => { + if (error instanceof TRPCError && error.code === "NOT_FOUND") { + if (!session) { + logger.debug("No home board found for anonymous user, redirecting to login"); + redirect("/auth/login"); } - throw error; - }), - auth(), - ]); + + notFound(); + } + + if (error instanceof TRPCError && error.code === "BAD_REQUEST") { + notFound(); + } + + throw error; + }); const itemsMap = board.items.reduce((acc, item) => { const existing = acc.get(item.kind); @@ -119,8 +127,11 @@ export const createBoardContentPage = >( }, }; } catch (error) { - // Ignore not found errors and return empty metadata - if (error instanceof TRPCError && error.code === "NOT_FOUND") { + // Ignore not found and bad-request errors and return empty metadata + if ( + error instanceof TRPCError && + (error.code === "NOT_FOUND" || error.code === "BAD_REQUEST") + ) { return {}; } diff --git a/packages/api/src/router/assistant.ts b/packages/api/src/router/assistant.ts index fa9279665..be3a1c60a 100644 --- a/packages/api/src/router/assistant.ts +++ b/packages/api/src/router/assistant.ts @@ -444,7 +444,8 @@ export const assistantRouter = createTRPCRouter({ .meta({ mcp: { enabled: true, - description: "Check whether Homarr Assistant is enabled and configured for the current user", + description: + "Check whether Homarr Assistant is enabled and configured, or available in demo mode, for the current user", }, }) .query(async ({ ctx }) => {