Redirect URL in Github Authorization Not Working #17374
QuentinRoggy
started this conversation in
Contribute to Supabase
Replies: 1 comment
-
cc @dijonmusters if you've got any immediate ideas |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug report
Describe the bug
I'm actually working on the tutorial provided by eggHead.io on twitter clone with supabase & nextJs.
I setup a login button like and it's look work fine because i'm redirected to github oath. But after, redirect does not work. I have a 500 error and no more explaination.
To Reproduce
This is my button code :
`
"use client";
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs";
export default function AuthButton() {
const supabase = createClientComponentClient();
const handleSignOut = async () => {
await supabase.auth.signOut();
};
const handleSignIn = async () => {
await supabase.auth.signInWithOAuth({
provider: "github",
options: {
redirectTo: "http://localhost:3000/auth/callback",
},
});
};
return (
<>
Login
Logout
</>
);
}
`
and here the route code :
`
import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs";
import { cookies } from "next/headers";
import { NextResponse, type NextRequest } from "next/server";
export async function GET(request: NextRequest) {
const requestUrl = new URL(request.url);
const code = requestUrl.searchParams.get("code");
if (code) {
const supabase = createRouteHandlerClient({ cookies });
await supabase.auth.exchangeCodeForSession(code);
}
return NextResponse.redirect(requestUrl.origin);
}
`
Expected behavior
Redirect back to the http://localhost:3000/ page after the GitHub Authorization.
System information
Beta Was this translation helpful? Give feedback.
All reactions