fix(backend): Deezer proxy route crashed the whole server on Express 5
`app.get('/api/deezer/*', …)` — a bare "*" — throws "Missing parameter name" in
Express 5's path-to-regexp at startup, so the server never came up and EVERY endpoint
(abs-proxy, romaji-overrides, deezer, …) failed with a CORS/ERR_FAILED in the browser.
Use a RegExp route instead, which registers cleanly on both Express 4 and 5. Verified
against express 5.2.1: bare "*" crashes, the regex is OK.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
68a9cdd7d1
commit
ad433c4dbc
1 file changed
+3
-1
@@ -327,7 +327,9 @@ app.get('/api/itunes/:endpoint', (req, res) => {
|
|||||||
// Deezer API proxy — the search source (Apple's /search returns 403 from server IPs). Deezer is
|
// Deezer API proxy — the search source (Apple's /search returns 403 from server IPs). Deezer is
|
||||||
// free, needs no key, and returns explicit versions + artist images + track durations. Covers
|
// free, needs no key, and returns explicit versions + artist images + track durations. Covers
|
||||||
// /search, /search/album, /search/artist, /album/{id}, /album/{id}/tracks, /artist/{id}/albums, …
|
// /search, /search/album, /search/artist, /album/{id}, /album/{id}/tracks, /artist/{id}/albums, …
|
||||||
app.get('/api/deezer/*', (req, res) => {
|
// Regex route (not '/api/deezer/*') — a bare "*" is an invalid path pattern in Express 5 and
|
||||||
|
// crashes the server at startup, taking every endpoint down with it.
|
||||||
|
app.get(/^\/api\/deezer\/(.+)/, (req, res) => {
|
||||||
const sub = String(req.params[0] || '').replace(/[^a-zA-Z0-9/_-]/g, '');
|
const sub = String(req.params[0] || '').replace(/[^a-zA-Z0-9/_-]/g, '');
|
||||||
const qs = new URLSearchParams(req.query).toString();
|
const qs = new URLSearchParams(req.query).toString();
|
||||||
const target = `https://api.deezer.com/${sub}${qs ? '?' + qs : ''}`;
|
const target = `https://api.deezer.com/${sub}${qs ? '?' + qs : ''}`;
|
||||||
|
|||||||
Reference in new issue
Block a user