Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#878: allow setting of baseURL from environment variable #911

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const topLevelDefaults = {
isEnabled: true,
disableServerSideAuth: false,
originEnvKey: 'AUTH_ORIGIN',
baseURLEnvKey: 'AUTH_BASE_URL',
sessionRefresh: {
enablePeriodically: false,
enableOnWindowFocus: true,
Expand Down Expand Up @@ -107,8 +108,10 @@ export default defineNuxtModule<ModuleOptions>({
const logger = useLogger(PACKAGE_NAME)

// 0. Assemble all options
const envBaseURLKey = userOptions.baseURLEnvKey as string
const envBaseURLEnvValue = process.env[envBaseURLKey]
const { origin, pathname = '/api/auth' } = getOriginAndPathnameFromURL(
userOptions.baseURL ?? ''
envBaseURLEnvValue ?? userOptions.baseURL ?? ''
)

const selectedProvider = userOptions.provider?.type ?? 'authjs'
Expand Down
1 change: 1 addition & 0 deletions src/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ export interface ModuleOptions {
* @default 'AUTH_ORIGIN'
*/
originEnvKey?: string
baseURLEnvKey?: string
/**
* Full url at which the app will run combined with the path to authentication. You can set this differently depending on your selected authentication-provider:
* - `authjs`: You must set the full URL, with origin and path in production. You can leave this empty in development
Expand Down
Loading