Description
Environment
- Operating System: Windows_NT
- Node Version: v20.13.1
- Nuxt Version: 3.17.3
- CLI Version: 3.25.1
- Nitro Version: 2.11.11
- Package Manager: pnpm@10.11.0
- Builder: -
- User Config: typescript, modules, auth, devtools, future, compatibilityDate, ssr, nitro, hub, css, runtimeConfig
- Runtime Modules: @nuxthub/core@0.8.27, @nuxt/eslint@1.3.1, @pinia/nuxt@0.11.0, @nuxt/ui@3.1.1, @nuxt/icon@1.12.0, @vueuse/nuxt@13.1.0, @sidebase/nuxt-auth@0.10.1
- Build Modules: -
Reproduction
- Create a new Nuxt 3 project with
@sidebase/nuxt-auth
v0.10.1 - Configure Azure AD authentication provider with all required credentials
- Set up authentication using the path-only approach:
baseURL: '/api/auth'
- Attempt to authenticate with Azure AD
Result: Client-side authentication requests go to /providers
instead of /api/auth/providers
, causing authentication failures.
Describe the bug
Issue Description
The documentation contains contradictory instructions regarding how baseURL
should be configured, specifically whether it should contain the full URL (protocol + domain + path) or just the path portion. This inconsistency directly leads to authentication failures with OAuth providers.
Investigation Steps Taken
- I've searched through open issues and discussions related to
baseURL
configuration and authentication failures - I've reviewed the documentation thoroughly and found direct contradictions
- I've tested both configuration approaches in a minimal project setup
Minimal Reproduction
- Create a new Nuxt 3 project with
@sidebase/nuxt-auth
v0.10.1 - Configure Azure AD authentication provider with all required credentials
- Set up authentication using the path-only approach:
baseURL: '/api/auth'
- Attempt to authenticate with Azure AD
Result: Client-side authentication requests go to /providers
instead of /api/auth/providers
, causing authentication failures.
Evidence of Contradictory Documentation
-
In
configuration.md
:baseURL: The full URL at which the app will run combined with the path to authentication.
-
In
url-resolutions.md
:export default defineNuxtConfig({ auth: { baseURL: 'https://example.com/api/auth', // ...
-
In multiple GitHub issues and deployment guides, only the path portion is used:
auth: { baseURL: '/api/auth' }
Root Cause Analysis
The inconsistency appears to be between server-side and client-side URL resolution. While the server correctly processes the configuration, the client-side components are not properly inheriting the base URL prefix, causing requests to incorrect endpoints.
This is particularly problematic with OAuth providers where precise URL construction is essential for the authentication flow to succeed.
Proposed Solution
Documentation must be updated to:
- Clearly specify the correct format for
baseURL
in both client and server contexts - Include version-specific guidance if the requirement has changed between versions
- Remove contradictory examples or explicitly label them as version-specific