fix(runtime-config): resolver MUSIC_DIR en tiempo de ejecución y no hornearlo en build; endpoints usan env absoluto o public fallback
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user