Agregar endpoints proxy para evitar CORS entre subdominios
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m5s

- /api/streams/list: proxy a streams.nucleoriofrio.com/api/streams
- /api/frigate/event: proxy a camaras.nucleoriofrio.com/api/events
- Actualizar composables para usar los proxies del backend
- Los iframes de streaming siguen usando URLs directas (sesion propia)
This commit is contained in:
2025-12-30 03:14:00 -06:00
parent 9e7e06d477
commit 8cc88c3dc4
4 changed files with 163 additions and 19 deletions

View File

@@ -0,0 +1,48 @@
/**
* Proxy endpoint para obtener la lista de streams de go2rtc
* Evita problemas de CORS/cookies entre subdominios
*/
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'
})
}
try {
const response = await fetch('https://streams.nucleoriofrio.com/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'
})
}
})