main
mula.liu 2026-01-20 12:36:44 +08:00
parent 15b970e6fa
commit d8e58e553a
3 changed files with 12 additions and 2 deletions

View File

@ -5,7 +5,7 @@ services:
build: .
container_name: nex-music-web
ports:
- "80:80"
- "8081:80"
restart: always
# If you want to mount the .env file dynamically or valid it locally
# env_file:

View File

@ -18,4 +18,10 @@ server {
expires 1y;
add_header Cache-Control "public, no-transform";
}
# Do not cache JSON data files
location ~* \.json$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
expires 0;
}
}

View File

@ -56,12 +56,16 @@ const resolveUrl = (url: string, baseUrl: string) => {
export const fetchPlaylist = async (url: string): Promise<TrackData[]> => {
try {
// Append timestamp to avoid cache
const cacheBuster = `t=${new Date().getTime()}`;
const urlWithCache = url.includes('?') ? `${url}&${cacheBuster}` : `${url}?${cacheBuster}`;
let response;
let fetchError;
// 1. Try direct fetch first
try {
response = await fetch(url);
response = await fetch(urlWithCache);
if (!response.ok) throw new Error('Direct fetch status not ok');
} catch (e) {
console.warn("Direct fetch failed, attempting proxy fallback 1.", e);