fix(runtime-config): resolver MUSIC_DIR en tiempo de ejecución y no hornearlo en build; endpoints usan env absoluto o public fallback
All checks were successful
build-and-deploy / build (push) Successful in 21s
build-and-deploy / deploy (push) Successful in 3s

This commit is contained in:
2025-08-10 03:03:22 -06:00
parent 81330de97e
commit e3e7374096
3 changed files with 9 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
import { promises as fs } from 'fs'
import { join, resolve, sep } from 'path'
import { join, resolve, sep, isAbsolute } from 'path'
import { createReadStream } from 'fs'
export default defineEventHandler(async (event) => {
@@ -30,9 +30,9 @@ export default defineEventHandler(async (event) => {
// Determine the music directory path
let musicDir: string
if (config.musicDirAbs || process.env.MUSIC_DIR) {
// Prefer absolute dir from runtimeConfig; fallback to env (resolved relative to repo root at build time)
musicDir = (config.musicDirAbs as string) || resolve(process.cwd(), process.env.MUSIC_DIR!)
if (process.env.MUSIC_DIR) {
// Resolve env to absolute
musicDir = isAbsolute(process.env.MUSIC_DIR) ? process.env.MUSIC_DIR : resolve(process.cwd(), process.env.MUSIC_DIR)
} else {
// Fallback to public/music
const defaultPublicPath = config.public?.musicPath || '/music'