blinkblinko
blinkblinko
Explore posts from servers
TTCTheo's Typesafe Cult
Created by blinkblinko on 3/22/2024 in #questions
Calling public trpc procedure redirects user to custom signin, causing an infinite loop
Fixed with
import { type NextRequest, NextResponse } from 'next/server';
import { withAuth } from 'next-auth/middleware';

const publicEndpoints = ['/auth/signin', '/auth/signout', '/api/system'];

const nextAuth = withAuth({
pages: {
signIn: '/auth/signin',
},
});

export async function middleware(req: NextRequest, res: NextResponse) {
if (publicEndpoints.includes(req.nextUrl.pathname)) {
return;
}

return nextAuth(req as any, res as any);
}
import { type NextRequest, NextResponse } from 'next/server';
import { withAuth } from 'next-auth/middleware';

const publicEndpoints = ['/auth/signin', '/auth/signout', '/api/system'];

const nextAuth = withAuth({
pages: {
signIn: '/auth/signin',
},
});

export async function middleware(req: NextRequest, res: NextResponse) {
if (publicEndpoints.includes(req.nextUrl.pathname)) {
return;
}

return nextAuth(req as any, res as any);
}
Really weird this isnt out the box hehe
6 replies
TTCTheo's Typesafe Cult
Created by blinkblinko on 3/22/2024 in #questions
Calling public trpc procedure redirects user to custom signin, causing an infinite loop
Hmm issue open since 2022
6 replies
TTCTheo's Typesafe Cult
Created by blinkblinko on 3/22/2024 in #questions
Calling public trpc procedure redirects user to custom signin, causing an infinite loop
eugh
6 replies
TTCTheo's Typesafe Cult
Created by blinkblinko on 3/22/2024 in #questions
Calling public trpc procedure redirects user to custom signin, causing an infinite loop
Im gunna have to roll back
6 replies
TTCTheo's Typesafe Cult
Created by blinkblinko on 3/22/2024 in #questions
Calling public trpc procedure redirects user to custom signin, causing an infinite loop
Same if I use the next api whats goin on...
6 replies