Skip to content

Commit cbcbd26

Browse files
committed
Add URL environment variable
- For differences in dev, preview, and production
1 parent 8bcb901 commit cbcbd26

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

.env.example

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
# Since the ".env" file is gitignored, you can use the ".env.example" file to
2-
# build a new ".env" file when you clone the repo. Keep this file up-to-date
3-
# when you add new variables to `.env`.
1+
NEXT_PUBLIC_SUPABASE_URL=
2+
NEXT_PUBLIC_SUPABASE_ANON_KEY=
43

5-
# This file will be committed to version control, so make sure not to have any
6-
# secrets in it. If you are cloning this repo, create a copy of this file named
7-
# ".env" and populate it with your secrets.
8-
9-
# When adding additional environment variables, the schema in "/env/schema.mjs"
10-
# should be updated accordingly.
11-
12-
# Example:
13-
# SERVERVAR="foo"
14-
# NEXT_PUBLIC_CLIENTVAR="bar"
4+
# Website URL for redirects
5+
URL=localhost:3000/

src/pages/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { Database } from '../utils/database'
99
import { useRouter } from "next/router";
1010
type Profiles = Database['public']['Tables']['profiles']['Row']
1111

12+
const REDIRECT_URL = process.env.URL
13+
1214
const Home: NextPage = () => {
1315
const supabaseClient = useSupabaseClient<Database>()
1416
const user = useUser();
@@ -62,7 +64,7 @@ const Home: NextPage = () => {
6264
<Layout>
6365
{
6466
(!session) ?
65-
<Auth redirectTo="http://localhost:3000/" appearance={{ theme: ThemeSupa }} supabaseClient={supabaseClient} providers={['google']} socialLayout="horizontal"/>
67+
<Auth redirectTo={REDIRECT_URL} appearance={{ theme: ThemeSupa }} supabaseClient={supabaseClient} providers={['google']} socialLayout="horizontal"/>
6668
:
6769
(!hasProfile) ?
6870
<ProfileForm session={session}/>

0 commit comments

Comments
 (0)