All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m1s
- go2rtc: http://192.168.87.29:1984 (configurable via GO2RTC_URL) - Frigate: http://192.168.87.29:5000 (configurable via FRIGATE_URL) - Evita problemas de DNS/red desde el contenedor
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
/**
|
|
* Proxy endpoint para obtener la lista de streams de go2rtc
|
|
* Evita problemas de CORS/cookies entre subdominios
|
|
* Usa URL interna del servidor go2rtc
|
|
*/
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
// Verificar autenticación via headers de Authentik
|
|
const headers = getRequestHeaders(event)
|
|
const username = headers['x-authentik-username']
|
|
|
|
if (!username) {
|
|
throw createError({
|
|
statusCode: 401,
|
|
message: 'No autenticado'
|
|
})
|
|
}
|
|
|
|
// URL interna de go2rtc (sin pasar por Traefik/Authentik)
|
|
const GO2RTC_URL = process.env.GO2RTC_URL || 'http://192.168.87.29:1984'
|
|
|
|
try {
|
|
const response = await fetch(`${GO2RTC_URL}/api/streams`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Accept': 'application/json'
|
|
}
|
|
})
|
|
|
|
if (!response.ok) {
|
|
throw createError({
|
|
statusCode: response.status,
|
|
message: `Error al obtener streams: ${response.statusText}`
|
|
})
|
|
}
|
|
|
|
const data = await response.json()
|
|
|
|
return data
|
|
} catch (error: unknown) {
|
|
console.error('[Streams Proxy] Error:', error)
|
|
|
|
if ((error as any).statusCode) {
|
|
throw error
|
|
}
|
|
|
|
throw createError({
|
|
statusCode: 500,
|
|
message: (error as Error)?.message || 'Error al obtener streams'
|
|
})
|
|
}
|
|
})
|