feat(WEB-127): add trpc to handle requests both serverside and clientside

This commit is contained in:
Simon Emanuelsson
2024-03-20 16:39:11 +01:00
parent 2087ac6c91
commit ec4da5798b
31 changed files with 422 additions and 40 deletions

View File

@@ -5,7 +5,6 @@ import { auth } from "@/auth"
import { findLocale } from "@/constants/locales"
import { pageNames } from "@/constants/myPages"
import { apiAuthPrefix } from "@/routes/api"
import { protectedRoutes } from "@/routes/protected"
import type { NextAuthRequest } from "next-auth"
@@ -69,11 +68,6 @@ const authedMiddleware = auth(authedMiddlewareFunction)
export async function middleware(request: NextRequest) {
const { nextUrl } = request
const isApiRoute = nextUrl.pathname.startsWith(apiAuthPrefix)
if (isApiRoute) {
return NextResponse.next()
}
const locale = findLocale(nextUrl.pathname)
if (!locale) {
//return <LocalePicker />
@@ -105,5 +99,5 @@ export const config = {
* public routes inside middleware.
* (https://clerk.com/docs/quickstarts/nextjs?utm_source=sponsorship&utm_medium=youtube&utm_campaign=code-with-antonio&utm_content=12-31-2023#add-authentication-to-your-app)
*/
matcher: ["/((?!.+\\.[\\w]+$|_next|en/test).*)", "/", "/(api)(.*)"],
matcher: ["/((?!.+\\.[\\w]+$|_next|en/test|api|trpc).*)"],
}