openvidu-dashboard: the unknown API route 404 names the full request path

chore/update-openvidu-actions-1.0.25
juancarmore 2026-10-27 10:42:41 +01:00
parent b20fad10c5
commit a03c8bb09c
2 changed files with 7 additions and 2 deletions

View File

@ -14,7 +14,9 @@ export function errorBody(code: ErrorCode, message: string, details?: Record<str
/** JSON 404 for `/api` paths no route answered, so the SPA fallback never serves them. */
export const apiNotFound: RequestHandler = (req, res) => {
res.status(404).json(errorBody('NOT_FOUND', `No API route for ${req.method} ${req.path}`));
res.status(404).json(
errorBody('NOT_FOUND', `No API route for ${req.method} ${req.originalUrl.split('?')[0] ?? ''}`)
);
};
interface BodyParserError {

View File

@ -57,7 +57,10 @@ describe('HTTP contract', () => {
const response = await request(app).get(path);
expect(response.status).toBe(404);
expect(response.headers['content-type']).toContain('application/json');
expect((response.body as { error: { code: string } }).error.code).toBe('NOT_FOUND');
expect((response.body as { error: { code: string; message: string } }).error).toEqual({
code: 'NOT_FOUND',
message: `No API route for GET ${path}`
});
});
it('hides unexpected errors behind INTERNAL_ERROR', async () => {