Agregar endpoints proxy para evitar CORS entre subdominios
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m5s
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:
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* Composable para gestionar eventos de Frigate
|
||||
* API: https://camaras.nucleoriofrio.com/api/events/{camera}/create
|
||||
* Usa proxy backend para evitar problemas de CORS/cookies entre subdominios
|
||||
* API Proxy: /api/frigate/event
|
||||
*/
|
||||
|
||||
export interface FrigateEventParams {
|
||||
@@ -24,14 +25,12 @@ export interface FrigateEventResponse {
|
||||
}
|
||||
|
||||
export const useFrigateEvents = () => {
|
||||
const BASE_URL = 'https://camaras.nucleoriofrio.com'
|
||||
|
||||
const isCreating = useState<boolean>('frigate_creating', () => false)
|
||||
const error = useState<string | null>('frigate_error', () => null)
|
||||
const lastEventId = useState<string | null>('frigate_last_event', () => null)
|
||||
|
||||
/**
|
||||
* Crea un evento en Frigate para una camara especifica
|
||||
* Crea un evento en Frigate para una camara especifica via proxy
|
||||
*/
|
||||
const createEvent = async (
|
||||
camera: string,
|
||||
@@ -41,17 +40,14 @@ export const useFrigateEvents = () => {
|
||||
error.value = null
|
||||
|
||||
try {
|
||||
// Extraer el nombre base de la camara (sin _main o _sub)
|
||||
const cameraName = camera.replace(/_main$|_sub$/, '')
|
||||
|
||||
const response = await $fetch<FrigateEventResponse>(
|
||||
`${BASE_URL}/api/events/${cameraName}/create`,
|
||||
{
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
body: params
|
||||
// Usar proxy backend para evitar CORS/cookies issues
|
||||
const response = await $fetch<FrigateEventResponse>('/api/frigate/event', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
camera,
|
||||
...params
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
if (response.event_id) {
|
||||
lastEventId.value = response.event_id
|
||||
|
||||
Reference in New Issue
Block a user