feat: add song download url api end point for 302

* This will redirect access from http://localhost:3000/song/url/v1?id=2756058128&level=exhigh to actual resource url
This commit is contained in:
RedSTARO
2026-02-26 20:12:43 +08:00
parent b027aca40a
commit 59241631db
2 changed files with 60 additions and 1 deletions
+7 -1
View File
@@ -210,6 +210,7 @@ async function consturctServer(moduleDefs) {
'daily_signin.js': '/daily_signin',
'fm_trash.js': '/fm_trash',
'personal_fm.js': '/personal_fm',
'song_download_url_v1_302.js': '/song/url/v1/302',
}
/**
@@ -221,7 +222,7 @@ async function consturctServer(moduleDefs) {
for (const moduleDef of moduleDefinitions) {
// Register the route.
app.use(moduleDef.route, async (req, res) => {
app.all(moduleDef.route, async (req, res) => {
;[req.query, req.body].forEach((item) => {
// item may be undefined (some environments / middlewares).
// Guard access to avoid "Cannot read properties of undefined (reading 'cookie')".
@@ -307,6 +308,11 @@ async function consturctServer(moduleDefs) {
}
}
}
if (moduleResponse.redirectUrl) {
res.redirect(moduleResponse.status || 302, moduleResponse.redirectUrl)
return
}
res.status(moduleResponse.status).send(moduleResponse.body)
} catch (/** @type {*} */ moduleResponse) {
logger.error(`${decode(req.originalUrl)}`, {