Fix chemin PDF en production pour l'API pdf-outline
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
En prod le PDF est dans .output/public/, pas dans public/. Cherche dans les deux emplacements (dev et prod). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
import { join } from 'node:path'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { readFileSync, existsSync } from 'node:fs'
|
||||
|
||||
export default defineEventHandler(async () => {
|
||||
const config = await readYaml('bookplayer.config.yml')
|
||||
const pdfFile = config?.book?.pdfFile || '/pdf/une-economie-du-don.pdf'
|
||||
const pdfPath = join(process.cwd(), 'public', pdfFile)
|
||||
|
||||
// En dev : public/, en prod : .output/public/
|
||||
const cwd = process.cwd()
|
||||
const candidates = [
|
||||
join(cwd, 'public', pdfFile),
|
||||
join(cwd, '.output', 'public', pdfFile),
|
||||
]
|
||||
const pdfPath = candidates.find(p => existsSync(p))
|
||||
if (!pdfPath) return []
|
||||
|
||||
let data: Uint8Array
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user