···6060 req.nextUrl.pathname.includes("/rss") ||
6161 req.nextUrl.pathname.includes("/atom") ||
6262 req.nextUrl.pathname.includes("/json");
6363+6464+ // Check if we've already completed auth (prevents redirect loop when cookies are disabled)
6565+ let authCompleted = req.nextUrl.searchParams.has("auth_completed");
6666+6367 if (
6468 !isStaticReq &&
6569 (!cookie || req.nextUrl.searchParams.has("refreshAuth")) &&
6666- !req.nextUrl.searchParams.has("auth_completed") &&
7070+ !authCompleted &&
6771 !hostname.includes("leaflet.pub")
6872 ) {
6973 return initiateAuthCallback(req);
7474+ }
7575+7676+ // If auth was completed but we still don't have a cookie, cookies might be disabled
7777+ // Continue without auth rather than looping
7878+ if (authCompleted && !cookie) {
7979+ console.warn(
8080+ "Auth completed but no cookie set - cookies may be disabled",
8181+ );
7082 }
7183 let aturi = new AtUri(pub?.uri);
7284 return NextResponse.rewrite(
···156168157169 let url = new URL(token.redirect);
158170 url.searchParams.set("auth_completed", "true");
159159- let response = NextResponse.redirect(token.redirect);
171171+ let response = NextResponse.redirect(url.toString());
160172 response.cookies.set("external_auth_token", token.auth_token || "null");
161173 return response;
162174}