Replies: 2 comments
This comment was marked as spam.
This comment was marked as spam.
-
|
I've been working on this project using Go and React and I keep on getting infinite reload in the browser anytime I run the code . I've tried everything possible even with A.I but I keep on getting the same result. middleware.ts import { NextRequest, NextResponse } from 'next/server'; // Real JWT expiry check — no library needed async function verifyJWT(token: string): Promise { const PUBLIC_PATHS = ['/', '/pricing', '/forgot-password']; export async function middleware(req: NextRequest) { // 3: Skip middleware for auth API, static files, and all api routes const accessToken = req.cookies.get('access_token')?.value; // 1: Actually check token expiry, not just existence // 2: Use .startsWith() so /login?callbackUrl=... still matches // Authenticated user hitting login/register → send to dashboard // Unauthenticated user hitting protected route // Inject org slug header for server components return NextResponse.next(); export const config = { ##token-refresh-quue.ts // Prevents multiple simultaneous refresh calls (race condition protection) async refresh(): Promise { } export const tokenRefreshQueue = new TokenRefreshQueue(); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions