Events: everything the backend serves is under /api (for 2.3.0)
The site and its API can share one address with one proxy rule (/api to the backend, everything else to the frontend). Status page at /api (/ redirects), /api/health, /api/docs/v2, /api/uploads. Stored upload paths stay /uploads/… and are given out as /api/uploads/…. Old paths still answer (/health, /uploads) or redirect (/docs, /docs/v2), so two-address sites keep working. DEPLOYMENT.md and the agent plan describe the single rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,9 +45,10 @@ function toAbsoluteUrl(req, url) {
|
||||
}
|
||||
return raw; // keep as-is if already absolute and not localhost
|
||||
}
|
||||
// Relative path like /uploads/... => prefix with request origin
|
||||
// Relative path like /uploads/... => prefix with request origin; uploads are served under
|
||||
// /api/uploads (2.3.0) so they reach the backend when the site and API share one address
|
||||
if (raw.startsWith('/')) {
|
||||
return `${req.protocol}://${req.get('host')}${raw}`;
|
||||
return `${req.protocol}://${req.get('host')}${raw.startsWith('/uploads/') ? `/api${raw}` : raw}`;
|
||||
}
|
||||
// Any other case, return as-is
|
||||
return raw;
|
||||
|
||||
Reference in New Issue
Block a user