So for example, the URL that is generated when I c...
# off-topic
c
So for example, the URL that is generated when I click my login with discord button, is there a way to get that URL say from the server side? or does it all have to be done in the client? I honestly might be completely misunderstanding how the
signIn({})
method works
a
hmm. not sure if you could do that. Do you want to use auth server side?
c
So I'm using remix when a user clicks the
login with discord
button, it delivers a post request to the same route which is then handled by remix's
ActionFunction
method that runs on server side. What I thought about doing from there is getting the url that is generated from the
Copy code
ts
supabase.auth.signIn({
  provider: 'discord',
});
method and the using the `ActionFunction`'s
redirect()
method to redirect the user to it. However, now that I'm thinking about it, I feel like I may be over complicating it drastically. My end goal was to have the user authenticated both on the server side and client side, that way I could use RLS from the server side as well. I really hope that made sense, it's 3am here so I might be missing the mark lol
a
so you're using Supabase only for Auth, but not for the backend?
c
I'm using supabase for it all, auth, backend and object storage
a
okay, AFAIK, once you're authenticated with Supabase, you're able to access the relevant data based on your RLS policies. There's no need for framework auth also
Atleast that's how it works for me in NextJS
In NextJS, you can "protect" pages with the getServerSideProps functions, so that only the authenticated user can access them.
Copy code
ts
export const getServerSideProps = withPageAuth({
  redirectTo: "/auth/login",
  async getServerSideProps(ctx) {
    const provider_token = ctx.req.cookies["sb-provider-token"];
    // Get logged in user's third-party id from metadata
    const { user } = await getUser(ctx);
    const { data } = await supabaseServerClient(ctx)
      .from("profile")
      .select("*")
      .eq("auth_id", user.id)
      .single();
    return { props: { profile: data } };
  },
});
this uses the
withPageAuth
helper exposed by Supabase, so if there's no logged in user, the page redirects. I don't need additional functionality.