https://supabase.com/ logo
Hey! I'm using Supabase Auth in my NextJS app as ...
# help
a
Hey! I'm using Supabase Auth in my NextJS app as below:
Copy code
ts
//import from packages
import React from "react";
import { Auth } from "@supabase/ui";
import { supabaseClient } from "@supabase/auth-helpers-nextjs";
//import from context and utils
//import from components
//import assets

export default function AllLoginOptions() {
  return (
    <div className="all-login-options">
      <Auth
        supabaseClient={supabaseClient}
        providers={["google"]}
        socialLayout="horizontal"
        socialButtonSize="large"
        className="text-warmwhite"
        redirectTo={`app.${process.env.APP_DOMAIN}/dashboard`}
      ></Auth>
    </div>
  );
}
I've changed the Site url for auth redirects in my the Supabase Project Authentication settings to my production domain. I've also added
localhost
to the list of allowed redirect urls. However, when I login in during dev (on localhost), the redirect happens to the production domain after auth. How can I redirect to
localhost
? Note: the
APP_DOMAIN
environment variable is set as
localhost
in dev, and as the production domain in prod.
n
Hello @aar2dee2! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
s
Does the redirect contain the
/dashboard
when you click the link albeit for the production domain?
a
No, it redirects to "/"
Hi, just checking to see if you have any thoughts on how to fix this
s
The dashboard page is using the
withPageAuth
I'm guessing and that would automatically redirect you back to the login page hence the
/
redirect. This is because the server-side gets rendered before the client-side and the login state isn't known until the
onAuthStateChange
runs (which is client side code) and notifies the server-side that you are logged in.
a
is there a way for the
withPageAuth
to pick different domains based on whether you're in dev or prod
s
This function doesn't have any domain specific code in it.