diff --git a/api/router.ts b/api/router.ts index d0e0ef8..d726955 100644 --- a/api/router.ts +++ b/api/router.ts @@ -266,9 +266,13 @@ router.get('/_config/media/files', async (ctx) => { const scope = ctx.req.query('path') ?? ''; try { const root = await originalsDir(user.email); + /* + Returned as-is. `listOriginals` already includes the prefix in every path it yields — it builds + `prefix/name` as it descends — so prefixing again produced + `Home_Page_Gallery/Home_Page_Gallery/…`, a real-looking path to nothing. + */ const files = await listOriginals(root, safeScope(scope)); - // Prefixed back to the scope, so what comes out is what a gallery item stores. - return ctx.json({ files: files.map((file) => (scope ? `${safeScope(scope)}/${file}` : file)) }); + return ctx.json({ files }); } catch (error) { return ctx.json({ error: (error as Error).message }, 400); }