diff --git a/.env.default b/.env.default new file mode 100644 index 00000000..83b364fb --- /dev/null +++ b/.env.default @@ -0,0 +1,29 @@ +DATABASE_URL=postgresql://user:password@localhost:5432/dbname + +# Optional if you use Vercel (defaults to VERCEL_URL). +# Necessary in development unless you use the vercel CLI (`vc dev`) +DRIFT_URL=http://localhost:3000 + +# Optional: The first user becomes an admin. Defaults to false +ENABLE_ADMIN=false + +# Required: Next auth secret is a required valid JWT secret. You can generate one with `openssl rand -hex 32` +NEXTAUTH_SECRET=7f8b8b5c5e5f5e5f5e5f5e5f5e5f5e5f5e5f5e5f5e5f5e5f5e5f5e5f5e5f5f5 + +# Required: but unnecessary if you use a supported host like Vercel +NEXTAUTH_URL=http://localhost:3000 + +# Optional: for locking your instance +REGISTRATION_PASSWORD= + +# Optional: for if you want GitHub oauth. Currently incompatible with the registration password +GITHUB_CLIENT_ID= +GITHUB_CLIENT_SECRET= + +# Optional: if you want to support credential auth (username/password, supports registration password) +# Defaults to true +CREDENTIAL_AUTH=true + +# Optional: +WELCOME_CONTENT= +WELCOME_TITLE= diff --git a/src/lib/config.ts b/src/lib/config.ts index eabe9284..cd94e412 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -76,7 +76,9 @@ export const config = (env: Environment): Config => { registration_password: env.REGISTRATION_PASSWORD ?? "", welcome_content: env.WELCOME_CONTENT ?? "Welcome to Drift.", welcome_title: env.WELCOME_TITLE ?? "Drift", - url: throwIfUndefined("DRIFT_URL"), + url: + throwIfUndefined("DRIFT_URL", true) || + `https://${throwIfUndefined("VERCEL_URL")}`, github_client_id: env.GITHUB_CLIENT_ID ?? "", github_client_secret: env.GITHUB_CLIENT_SECRET ?? "", nextauth_secret: throwIfUndefined("NEXTAUTH_SECRET"),