supabase icon indicating copy to clipboard operation
supabase copied to clipboard

logIn redirect to localhost

Open Tonight11 opened this issue 2 years ago • 4 comments

Hello guys. i have deployed site on netlify https://nuxt-ts.netlify.app/login. when i`m trying logIn with GitHub, it redirect me to localhost with access and refresh token. How to solve this problem?

Tonight11 avatar Apr 01 '23 22:04 Tonight11

You can redirect to your site by adding the parameter in your login method. See example below:

const { data, error } = await supabase.auth.signInWithOAuth({
  provider: 'github'
  options: {
    redirectTo: 'https://example.com/welcome'
  }
})

You can check the docs for more info: https://supabase.com/docs/reference/javascript/auth-signinwithoauth

Then on your Supabase project, go to Authentication > URL Configuration then add your site URL to the Redirect URLs.

larrasu avatar Apr 03 '23 10:04 larrasu

Now it just refresh the page and not giving authenticated user information `

const supabase = useSupabaseAuthClient();
const user = useSupabaseUser();
const location = useRuntimeConfig().public.siteUrl;
console.log(`${location}${query.redirectTo}`);
onMounted(() => {
	watchEffect(async () => {
		if (user.value) {
			await navigateTo(query.redirectTo as string, {
				replace: true,
			});
		}
	});
});
const login = async (provider: 'github') => {
	const redirectTo: string = `${location}${query.redirectTo}`;
	const { error } = await supabase.auth.signInWithOAuth({
		provider,
		options: { redirectTo },
	});
	if (error) {
		console.error(error);
	}
};`

i mean, now it`s not even giving me access token. it was: like "localhost:3000#access_token=12312312" on deployment server. now even this disappear

supabase Site URL: http://localhost:3001/ Redirect URLs

https://nuxt-ts.netlify.app/ https://nuxt-ts.netlify.app/**

Tonight11 avatar Apr 06 '23 19:04 Tonight11

For property "redirectTo" try to write URL something like "http://localhost:3000/${location}${query.redirectTo} "

MartCube avatar Apr 24 '23 11:04 MartCube