Commit 13247d86 authored by Aryan Noshirvani's avatar Aryan Noshirvani

Fix download_url hardcoded to port 8000 regardless of instance

Both /music/upload and /remix/{job_id} (fixed in the previous commit's
diff already for remix.py) built their download_url from a hardcoded
"http://91.234.52.134:8000" - meaning the dev instance (port 8001)
was handing back main's port for files it had actually produced. It
happened to still work, since both instances share the same physical
/root/antigrav-stax-audio/downloads directory, but it's semantically
wrong and would break the moment that's no longer true.

Found via the same real-browser Playwright pass as the previous fix -
the Tag & Identify panel's result audio player pointed at port 8000
while running against the port 8001 instance. Now derives the URL
from request.base_url instead, so it always reflects whichever host
actually served the request.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
parent 7d812f92
...@@ -5,7 +5,7 @@ import urllib.parse ...@@ -5,7 +5,7 @@ import urllib.parse
import asyncio import asyncio
import google.generativeai as genai import google.generativeai as genai
from fastapi import APIRouter, HTTPException, UploadFile, File from fastapi import APIRouter, HTTPException, Request, UploadFile, File
from pydantic import BaseModel from pydantic import BaseModel
from src.services.music_identification import identify_with_gemini, identify_audio, fetch_lyrics from src.services.music_identification import identify_with_gemini, identify_audio, fetch_lyrics
...@@ -37,7 +37,7 @@ async def tag_music(req: TagRequest): ...@@ -37,7 +37,7 @@ async def tag_music(req: TagRequest):
} }
@router.post("/upload", response_model=TagResponse) @router.post("/upload", response_model=TagResponse)
async def upload_direct(file: UploadFile = File(...)): async def upload_direct(request: Request, file: UploadFile = File(...)):
temp_filename = f"/root/antigrav-stax-audio/temp/{uuid.uuid4()}_{file.filename}" temp_filename = f"/root/antigrav-stax-audio/temp/{uuid.uuid4()}_{file.filename}"
with open(temp_filename, "wb") as buffer: with open(temp_filename, "wb") as buffer:
shutil.copyfileobj(file.file, buffer) shutil.copyfileobj(file.file, buffer)
...@@ -80,10 +80,10 @@ async def upload_direct(file: UploadFile = File(...)): ...@@ -80,10 +80,10 @@ async def upload_direct(file: UploadFile = File(...)):
os.remove(temp_filename) os.remove(temp_filename)
quoted_filename = urllib.parse.quote(final_filename) quoted_filename = urllib.parse.quote(final_filename)
return { return {
"status": "success", "status": "success",
"download_url": f"http://91.234.52.134:8000/downloads/{quoted_filename}", "download_url": f"{str(request.base_url).rstrip('/')}/downloads/{quoted_filename}",
"metadata": { "metadata": {
"title": candidate.get('title', 'Unknown'), "title": candidate.get('title', 'Unknown'),
"artist": candidate.get('artist', 'Unknown'), "artist": candidate.get('artist', 'Unknown'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment