[GH-ISSUE #10] Fix redundant "/audio/" prefix causing 404/NS_BINDING_ABORTED and generation failures. #12

Closed
opened 2026-02-26 21:30:43 +03:00 by kerem · 1 comment
Owner

Originally created by @Konrro on GitHub (Feb 4, 2026).
Original GitHub issue: https://github.com/fspecii/ace-step-ui/issues/10

The app generates double slashes in URLs (e.g., /audio//audio/...) because getPublicUrl in local.ts adds the prefix even if the key already contains it. This causes Python to fail when locating reference tracks.

Normalize the key in storage/local.ts or ensure consistency in how paths are stored in the database.

After some debug, i find the problem (inside 'local.ts'):

Replace the function at line 17 (async upload) with this code:

  async upload(key: string, data: Buffer, _contentType: string): Promise<string> {
    const filepath = path.join(this.audioDir, key);
    await mkdir(path.dirname(filepath), { recursive: true });
    await writeFile(filepath, data);
    return `/audio/${key}`;
  }

  async getUrl(key: string, _expiresIn?: number): Promise<string> {
    return `/audio/${key}`;
  }

getPublicUrl(key: string): string {
  const cleanKey = key.startsWith('/audio/') ? key.slice('/audio/'.length) : key;
  return `/audio/${cleanKey.replace(/^\/+/, '')}`;
}

It fixed the bad url when an audio file is upload as reference.

Note: I also recommend checking upload and getUrl in the same file to ensure they don't redundantly prepend the prefix, keeping the storage logic consistent.

Originally created by @Konrro on GitHub (Feb 4, 2026). Original GitHub issue: https://github.com/fspecii/ace-step-ui/issues/10 The app generates double slashes in URLs (e.g., /audio//audio/...) because getPublicUrl in local.ts adds the prefix even if the key already contains it. This causes Python to fail when locating reference tracks. Normalize the key in storage/local.ts or ensure consistency in how paths are stored in the database. After some debug, i find the problem (inside 'local.ts'): Replace the function at line 17 (async upload) with this code: ``` async upload(key: string, data: Buffer, _contentType: string): Promise<string> { const filepath = path.join(this.audioDir, key); await mkdir(path.dirname(filepath), { recursive: true }); await writeFile(filepath, data); return `/audio/${key}`; } async getUrl(key: string, _expiresIn?: number): Promise<string> { return `/audio/${key}`; } getPublicUrl(key: string): string { const cleanKey = key.startsWith('/audio/') ? key.slice('/audio/'.length) : key; return `/audio/${cleanKey.replace(/^\/+/, '')}`; } ``` It fixed the bad url when an audio file is upload as reference. Note: I also recommend checking upload and getUrl in the same file to ensure they don't redundantly prepend the prefix, keeping the storage logic consistent.
kerem closed this issue 2026-02-26 21:30:43 +03:00
Author
Owner

@fspecii commented on GitHub (Feb 5, 2026):

Hi @Konrro,

Thanks for the detailed report! This was indeed a real bug — the upload() function was returning /audio/${key} which caused double prefixes when the URL was later passed through getUrl() or getPublicUrl().

This has already been fixed:

  • upload() now returns just the raw key (without the /audio/ prefix)
  • getPublicUrl() has a guard to prevent double-prefixing

Closing as resolved. Thanks for digging into this!

<!-- gh-comment-id:3856580061 --> @fspecii commented on GitHub (Feb 5, 2026): Hi @Konrro, Thanks for the detailed report! This was indeed a real bug — the `upload()` function was returning `/audio/${key}` which caused double prefixes when the URL was later passed through `getUrl()` or `getPublicUrl()`. This has already been fixed: - `upload()` now returns just the raw `key` (without the `/audio/` prefix) - `getPublicUrl()` has a guard to prevent double-prefixing Closing as resolved. Thanks for digging into this!
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ace-step-ui#12
No description provided.