Spell out which Coolify backup vars belong on AIGen vs xAIGen.

A URL in BACKUP_INGEST_TOKEN was treated as a missing token. Errors now say to put the URL on AIGen and the same secret on both apps.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-01 19:14:34 -05:00
co-authored by Cursor
parent 8b414044cd
commit f25e1bcc8a
4 changed files with 65 additions and 13 deletions
+7 -3
View File
@@ -1,3 +1,4 @@
import { backupIngestSecret } from '~/server/utils/backupStudio'
import { passwordAuthEnabled, privateInstanceId } from '~/server/utils/localAuth'
import { saveStill } from '~/server/utils/library'
@@ -7,9 +8,12 @@ function ingestOwner() {
}
function assertIngestToken(event: Parameters<typeof getHeader>[0]) {
const expected = String(useRuntimeConfig().backupIngestToken || process.env.BACKUP_INGEST_TOKEN || '').trim()
if (!expected) {
throw createError({ statusCode: 503, statusMessage: 'Backup ingest is not configured' })
const expected = backupIngestSecret()
if (!expected || /^https?:\/\//i.test(expected)) {
throw createError({
statusCode: 503,
statusMessage: 'Set BACKUP_INGEST_TOKEN on xAIGen to the same secret as BACKUP_STUDIO_TOKEN on AIGen, not a URL.'
})
}
const header = String(getHeader(event, 'authorization') || '')
if (header !== `Bearer ${expected}`) {
@@ -1,17 +1,17 @@
import { readFileSync } from 'node:fs'
import { isXaigenStudio } from '~/utils/videoModels'
import { backupStudioConfigError, backupStudioTarget } from '~/server/utils/backupStudio'
import { assertLibraryOwner, getStill, stillPath } from '~/server/utils/library'
export default defineEventHandler(async (event) => {
if (isXaigenStudio()) {
throw createError({ statusCode: 404, statusMessage: 'Not found' })
}
const config = useRuntimeConfig()
const url = String(config.backupStudioUrl || process.env.BACKUP_STUDIO_URL || '').replace(/\/$/, '')
const token = String(config.backupStudioToken || process.env.BACKUP_STUDIO_TOKEN || '').trim()
if (!url || !token) {
throw createError({ statusCode: 503, statusMessage: 'Backup studio is not configured' })
const missing = backupStudioConfigError()
if (missing) {
throw createError({ statusCode: 503, statusMessage: missing })
}
const { url, token } = backupStudioTarget()
const { owner } = assertLibraryOwner(event)
const id = String(getRouterParam(event, 'id') || '')
const still = getStill(owner, id)
@@ -31,7 +31,7 @@ export default defineEventHandler(async (event) => {
const message = await res.text().catch(() => '')
throw createError({
statusCode: res.status === 401 ? 502 : res.status,
statusMessage: message || 'Backup studio refused the still'
statusMessage: message || 'xAIGen refused the still. Check BACKUP_INGEST_TOKEN matches AIGen BACKUP_STUDIO_TOKEN.'
})
}
return { ok: true }