Skip to content

Commit

Permalink
Add nextauth internal url (#153)
Browse files Browse the repository at this point in the history
* Add nextauth_internal_url

* Add NEXTAUTH_URL_INTERNAL option

---------

Co-authored-by: KM Koushik <[email protected]>
  • Loading branch information
batizisanya and KMKoushik authored Dec 13, 2024
1 parent 0363080 commit 5ff2edb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ DATABASE_URL="postgresql://splitpro:password@localhost:54321/splitpro"
NEXTAUTH_SECRET="secret"
NEXTAUTH_URL="http://localhost:3000"

# If provided, server-side calls will use this instead of NEXTAUTH_URL. Useful in environments when the server doesn't have access to the canonical URL of your site.
# NEXTAUTH_URL_INTERNAL="http://localhost:3000"


# Enable sending invites
ENABLE_SENDING_INVITES=false
#********* END OF REQUIRED ENV VARS *********
Expand Down
5 changes: 5 additions & 0 deletions src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export const env = createEnv({
// VERCEL_URL doesn't include `https` so it cant be validated as a URL
process.env.VERCEL ? z.string() : z.string().url(),
),
NEXTAUTH_URL_INTERNAL: z.preprocess(
(str) => process.env.VERCEL_URL ?? str,
process.env.VERCEL ? z.string() : z.string().url(),
),
ENABLE_SENDING_INVITES: z.boolean(),
FROM_EMAIL: z.string().optional(),
EMAIL_SERVER_HOST: z.string().optional(),
Expand Down Expand Up @@ -64,6 +68,7 @@ export const env = createEnv({
NODE_ENV: process.env.NODE_ENV,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
NEXTAUTH_URL_INTERNAL: process.env.NEXTAUTH_URL_INTERNAL ?? process.env.NEXTAUTH_URL,
ENABLE_SENDING_INVITES: process.env.ENABLE_SENDING_INVITES === 'true',
FROM_EMAIL: process.env.FROM_EMAIL,
EMAIL_SERVER_HOST: process.env.EMAIL_SERVER_HOST,
Expand Down

0 comments on commit 5ff2edb

Please sign in to comment.