Add debug logging and config endpoint
- Add console.log in oauth-authentik.ts to debug config - Add /api/debug-config endpoint to verify env vars - Helps diagnose missing serverUrl issue
This commit is contained in:
31
nuxt4-app/server/api/debug-config.get.ts
Normal file
31
nuxt4-app/server/api/debug-config.get.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Debug Config Endpoint
|
||||
* Ruta: /api/debug-config
|
||||
*
|
||||
* TEMPORAL: Para verificar que las variables de entorno se estén cargando
|
||||
* BORRAR EN PRODUCCIÓN
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
const runtimeConfig = useRuntimeConfig(event)
|
||||
|
||||
return {
|
||||
oauth: {
|
||||
authentik: {
|
||||
clientId: runtimeConfig.oauth.authentik.clientId ? 'SET (hidden)' : 'MISSING',
|
||||
clientSecret: runtimeConfig.oauth.authentik.clientSecret ? 'SET (hidden)' : 'MISSING',
|
||||
serverUrl: runtimeConfig.oauth.authentik.serverUrl || 'MISSING',
|
||||
redirectURL: runtimeConfig.oauth.authentik.redirectURL || 'MISSING',
|
||||
}
|
||||
},
|
||||
public: {
|
||||
appUrl: runtimeConfig.public.appUrl || 'MISSING'
|
||||
},
|
||||
env: {
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
// Verificar directamente las env vars
|
||||
NUXT_OAUTH_AUTHENTIK_SERVER_URL: process.env.NUXT_OAUTH_AUTHENTIK_SERVER_URL || 'MISSING',
|
||||
NUXT_OAUTH_AUTHENTIK_REDIRECT_URL: process.env.NUXT_OAUTH_AUTHENTIK_REDIRECT_URL || 'MISSING',
|
||||
NUXT_PUBLIC_APP_URL: process.env.NUXT_PUBLIC_APP_URL || 'MISSING',
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -54,6 +54,14 @@ export function oauthAuthentikEventHandler({
|
||||
return eventHandler(async (event: H3Event) => {
|
||||
const runtimeConfig = useRuntimeConfig(event)
|
||||
|
||||
// Debug: Log configuration
|
||||
console.log('OAuth Authentik Config:', {
|
||||
clientId: runtimeConfig.oauth.authentik.clientId ? '***' : 'MISSING',
|
||||
clientSecret: runtimeConfig.oauth.authentik.clientSecret ? '***' : 'MISSING',
|
||||
serverUrl: runtimeConfig.oauth.authentik.serverUrl,
|
||||
redirectURL: runtimeConfig.oauth.authentik.redirectURL,
|
||||
})
|
||||
|
||||
// Merge config with defaults
|
||||
const authentikConfig = defu(config, {
|
||||
clientId: runtimeConfig.oauth.authentik.clientId,
|
||||
|
||||
Reference in New Issue
Block a user