mirror of https://github.com/OpenVidu/openvidu.git
openvidu-dashboard: the unknown API route 404 names the full request path
parent
b20fad10c5
commit
a03c8bb09c
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue