Ā© 2026 Hedgehog Software, LLC
import { type NextRequest, NextResponse } from "next/server"; import { headers } from "next/headers"; import { auth } from "@/lib/auth"; export async function middleware(request: NextRequest) { const pathname = request.nextUrl.pathname; if (!pathname.startsWith("/dashboard")) { return NextResponse.next(); } const session = await auth.api.getSession({ headers: request.headers, }); if (session?.user?.scopes.includes("guilds")) { return NextResponse.next(); } const response = await auth.api.signInSocial({ body: { provider: "discord", callbackURL: pathname }, headers: await headers(), }); console.log("Redirecting to: ", response.url); return NextResponse.redirect(response.url); } export const config = { matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"], };
/callback/discord
{"redirect_uri": ["Not a well formed URL."]}