I am building a Flask + JavaScript web app that works like a lightweight music player
Backend (Flask):
-
Uses
yt-dlpto extract audio stream URLs from YouTube. -
Uses an api for searching the song info like video id and all
-
Has endpoints:
/search?q=โ returns songs & videos with title, artist, thumbnail, videoId./stream/<video_id>โ returns playable url/related/<video_id>โ returns related tracks.
-
Currently deployed on Vercel.
-
Frontend (JS):
- Calls Flask API endpoints with
fetch(). - Plays the audio stream in the browser.
- Also fetches lyrics from
https://lrclib.net/api/getusing title + artist.
- Calls Flask API endpoints with
-
Problem:
- On front end after fetching the data from /stream endpoint i get the data and the js code shows it on the console (have used console log for that) and right after showing that info the page reloads automatically
-
What Iโve Tried:
- when i remove the cookiefile option in the yt-dlp options then the front end doesnt reload but for the yt-dlp authentication i need to pass the cookiefile
i want to solve the page reload issue and that the only prob