fix: more reliable 404 responses for .api endpoint
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled

This fix avoids some situations where a non-existing route hangs instead
of responding with 404.
This commit is contained in:
KernelDeimos
2026-01-27 15:34:33 -05:00
committed by Eric Dubé
parent a8dc62ef80
commit e7443338fb
@@ -79,6 +79,13 @@ class WebServerService extends BaseService {
return res.sendStatus(200);
});
// Catch-all 404 for unmatched routes (e.g. api subdomain with unknown path)
// There seem to be some cases (ex: other subdomains) where this doesn't work
// as intended still, but this is an improvement over the previous behavior.
app.use((req, res) => {
res.status(404).send('Not Found');
});
this.log.debug('web server setup done');
}