diff --git a/src/lib/server/middlewares/authenticate.ts b/src/lib/server/middlewares/authenticate.ts index ad8c585..cc635b4 100644 --- a/src/lib/server/middlewares/authenticate.ts +++ b/src/lib/server/middlewares/authenticate.ts @@ -4,7 +4,7 @@ import { authenticate, AuthenticationError } from "$lib/server/modules/auth"; export const authenticateMiddleware: Handle = async ({ event, resolve }) => { const { pathname, search } = event.url; - if (pathname === "/api/auth/login" || pathname.startsWith("/trpc")) { + if (pathname === "/api/auth/login") { return await resolve(event); } @@ -24,7 +24,7 @@ export const authenticateMiddleware: Handle = async ({ event, resolve }) => { }); } catch (e) { if (e instanceof AuthenticationError) { - if (pathname === "/auth/login") { + if (pathname === "/auth/login" || pathname.startsWith("/api/trpc")) { return await resolve(event); } else if (pathname.startsWith("/api")) { error(e.status, e.message); diff --git a/src/routes/trpc/[...trpc]/+server.ts b/src/routes/api/trpc/[trpc]/+server.ts similarity index 94% rename from src/routes/trpc/[...trpc]/+server.ts rename to src/routes/api/trpc/[trpc]/+server.ts index 052ee09..ec1320a 100644 --- a/src/routes/trpc/[...trpc]/+server.ts +++ b/src/routes/api/trpc/[trpc]/+server.ts @@ -5,7 +5,7 @@ import type { RequestHandler } from "./$types"; const trpcHandler: RequestHandler = (event) => fetchRequestHandler({ - endpoint: "/trpc", + endpoint: "/api/trpc", req: event.request, router: appRouter, createContext: () => createContext(event), diff --git a/src/trpc/client.ts b/src/trpc/client.ts index 433a743..dbf4e80 100644 --- a/src/trpc/client.ts +++ b/src/trpc/client.ts @@ -6,7 +6,7 @@ const createClient = (fetch: typeof globalThis.fetch) => createTRPCClient({ links: [ httpBatchLink({ - url: "/trpc", + url: "/api/trpc", fetch, }), ],