Skip to content

fix(admin): use useRuntimeConfig instead of process.env for provider detection#451

Merged
larbish merged 2 commits into
nuxt-content:mainfrom
surohak:fix/admin-handler-use-runtime-config
May 7, 2026
Merged

fix(admin): use useRuntimeConfig instead of process.env for provider detection#451
larbish merged 2 commits into
nuxt-content:mainfrom
surohak:fix/admin-handler-use-runtime-config

Conversation

@surohak
Copy link
Copy Markdown
Contributor

@surohak surohak commented May 6, 2026

Description

The /_studio admin route handler reads process.env directly at runtime to detect which auth providers are configured. On platforms like AWS Amplify (and similar serverless platforms), environment variables are available during nuxt build but are not forwarded to the Lambda/function runtime.

This causes a 404 with "No authentication provider found" even though:

  • The env vars exist at build time
  • The module correctly populates runtimeConfig.studio.auth from those vars
  • All other auth handlers already use useRuntimeConfig()

Root Cause

// admin.ts — reads process.env at runtime (broken on Amplify)
const hasGithub = process.env.STUDIO_GITHUB_CLIENT_ID && 'github'

Meanwhile github.get.ts correctly uses:

const studioConfig = useRuntimeConfig(event).studio

Fix

Replace process.env.STUDIO_* reads with useRuntimeConfig(event).studio.auth.* lookups, matching the pattern already used by all other auth route handlers.

Changes

  • src/module/src/runtime/server/routes/admin.ts: Use useRuntimeConfig(event).studio.auth for provider detection

Fixes #384

…detection

The admin route handler reads process.env directly at runtime to detect
which auth providers are configured. On platforms like AWS Amplify where
build-time environment variables are not forwarded to the Lambda runtime,
this causes a 404 with "No authentication provider found" even though
the module correctly populates runtimeConfig at build time.

All other auth handlers (github.get, gitlab.get, google.get, sso.get)
already use useRuntimeConfig(event).studio — this aligns the admin
handler with the same pattern.

Fixes nuxt-content#384
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 6, 2026

Someone is attempting to deploy a commit to the Nuxt Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread src/module/src/runtime/server/routes/admin.ts Outdated
@larbish larbish merged commit a020243 into nuxt-content:main May 7, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin handler reads process.env directly instead of runtimeConfig, causing 404 on platforms where build-time env vars aren't available at runtime

2 participants