修改了api的地址
This commit is contained in:
16
index.html
16
index.html
@@ -138,6 +138,8 @@
|
||||
<script type="text/babel">
|
||||
const { useState, useEffect, useRef, useMemo, useCallback } = React;
|
||||
|
||||
// Use relative path for API proxy to avoid CORS issues
|
||||
// Nginx forwards /api/ to sync-server, which proxies /music-api to music-dl.sayqz.com
|
||||
const API_BASE = "/api/music-api";
|
||||
// Use relative path for sync service, assuming Nginx proxy is configured to forward /api/kv to the sync service
|
||||
const SYNC_API_BASE = "/api";
|
||||
@@ -256,7 +258,7 @@
|
||||
const api = {
|
||||
search: async (keyword, source = 'netease', page = 1) => {
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/api/?type=search&keyword=${encodeURIComponent(keyword)}&source=${source}&page=${page}`);
|
||||
const res = await fetch(`${API_BASE}?type=search&keyword=${encodeURIComponent(keyword)}&source=${source}&page=${page}`);
|
||||
const data = await res.json();
|
||||
if (data.code === 200) {
|
||||
const payload = data.data || {};
|
||||
@@ -269,14 +271,14 @@
|
||||
}
|
||||
},
|
||||
getSongUrl: (id, source, br = '320k') => {
|
||||
return `${API_BASE}/api/?source=${source}&id=${id}&type=url&br=${br}`;
|
||||
return `${API_BASE}?source=${source}&id=${id}&type=url&br=${br}`;
|
||||
},
|
||||
getPicUrl: (id, source) => {
|
||||
return `${API_BASE}/api/?source=${source}&id=${id}&type=pic`;
|
||||
return `${API_BASE}?source=${source}&id=${id}&type=pic`;
|
||||
},
|
||||
getLrc: async (id, source) => {
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/api/?source=${source}&id=${id}&type=lrc`);
|
||||
const res = await fetch(`${API_BASE}?source=${source}&id=${id}&type=lrc`);
|
||||
const text = await res.text();
|
||||
return text;
|
||||
} catch (e) {
|
||||
@@ -309,7 +311,7 @@
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/api/?source=${source}&type=toplists`);
|
||||
const res = await fetch(`${API_BASE}/?source=${source}&type=toplists`);
|
||||
const data = await res.json();
|
||||
if (data.code === 200) {
|
||||
// 兼容多种返回结构:data本身是数组,或者data.list是数组
|
||||
@@ -326,7 +328,7 @@
|
||||
},
|
||||
getTopListSongs: async (id, source) => {
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/api/?source=${source}&id=${id}&type=toplist`);
|
||||
const res = await fetch(`${API_BASE}/?source=${source}&id=${id}&type=toplist`);
|
||||
const data = await res.json();
|
||||
if (data.code === 200) {
|
||||
const list = Array.isArray(data.data) ? data.data : (data.data.list || data.data.tracks || []);
|
||||
@@ -340,7 +342,7 @@
|
||||
},
|
||||
getPlaylist: async (id, source = 'netease') => {
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/api/?type=playlist&id=${id}&source=${source}`);
|
||||
const res = await fetch(`${API_BASE}/?type=playlist&id=${id}&source=${source}`);
|
||||
const data = await res.json();
|
||||
if (data.code === 200 && data.data && Array.isArray(data.data.list)) {
|
||||
return normalizeSongList(data.data.list);
|
||||
|
||||
Reference in New Issue
Block a user