mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
This PR updates the `with-supabase` template to better auth pages, Tailwind v4 and newest `components.json` for full compatibility with shadcn/ui. The `(auth-pages)` folder has been removed. For auth, the template is now using the [password based auth block](https://supabase.com/ui/docs/nextjs/password-based-auth) from the Supabase UI Library which makes it easier to update it and keep it up-to-date. --------- Co-authored-by: Lee Robinson <[email protected]>
31 lines
1005 B
TypeScript
31 lines
1005 B
TypeScript
import { createClient } from "@/lib/supabase/server";
|
|
import { type EmailOtpType } from "@supabase/supabase-js";
|
|
import { redirect } from "next/navigation";
|
|
import { type NextRequest } from "next/server";
|
|
|
|
export async function GET(request: NextRequest) {
|
|
const { searchParams } = new URL(request.url);
|
|
const token_hash = searchParams.get("token_hash");
|
|
const type = searchParams.get("type") as EmailOtpType | null;
|
|
const next = searchParams.get("next") ?? "/";
|
|
|
|
if (token_hash && type) {
|
|
const supabase = await createClient();
|
|
|
|
const { error } = await supabase.auth.verifyOtp({
|
|
type,
|
|
token_hash,
|
|
});
|
|
if (!error) {
|
|
// redirect user to specified redirect URL or root of app
|
|
redirect(next);
|
|
} else {
|
|
// redirect the user to an error page with some instructions
|
|
redirect(`/auth/error?error=${error?.message}`);
|
|
}
|
|
}
|
|
|
|
// redirect the user to an error page with some instructions
|
|
redirect(`/auth/error?error=No token hash or type`);
|
|
}
|