You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using query parameters in the URL of a route does not work. The documentation recommends to read the path-to-regexp doc. Here it is described that the question mark (?) must be escaped: https://www.npmjs.com/package/path-to-regexp#modifiers
As described I escaped the question mark: /os/api/ecs/search\\?search=01.7541914201.0002.18
However, I get a 404 response back from the mock api server. Am I doing something wrong here or missing something?
To reproduce the bug, it is enough to set up a minimal setup, with the following route:
The following appears in the debug logs:
11:22:11:47 [debug][server] Request received | GET => /os/api/ecs/search?search=01.7541914201.0002.18 | Assigned id: 3ed515d7-b7ef-4593-832d-1bd1ed12479d
11:22:11:47 [debug][server] Sending Not found response | GET => /os/api/ecs/search?search=01.7541914201.0002.18 | 3ed515d7-b7ef-4593-832d-1bd1ed12479d
11:22:11:47 [error][server] Sending Error 'Not Found' | 3ed515d7-b7ef-4593-832d-1bd1ed12479d
I am using the following software versions:
npm: 9.5.0
Node: v18.14.2
If you are missing some information, please let me know.
Thanks for your help and best regards
The text was updated successfully, but these errors were encountered:
Hi @Scilor3 , you're right, the server does not support defining different route variants for specific query params. This is because it uses express under the hood, and it does not consider query strings as part of the route path. So, for the moment you should remove the query param from the route path, and, if you want to send different responses based on the query params, then you should use amiddleware route variant, in which you could get the query params through req.query and act in consequence.
Anyway, this is something that should be explained better in the documentation, and maybe we can also investigate how to support defining query params in the route paths out of the box.
Using query parameters in the URL of a route does not work. The documentation recommends to read the path-to-regexp doc. Here it is described that the question mark (?) must be escaped: https://www.npmjs.com/package/path-to-regexp#modifiers
As described I escaped the question mark: /os/api/ecs/search\\?search=01.7541914201.0002.18
However, I get a 404 response back from the mock api server. Am I doing something wrong here or missing something?
To reproduce the bug, it is enough to set up a minimal setup, with the following route:
{ id: 'get-search', url: '/os/api/ecs/search\\?search=01.7541914201.0002.18', method: 'GET', variants: [ { id: 'default', type: 'json', options: { status: 200, body: defaultSearch, }, }, ], }
and call the URL in the browser, e.g. http://localhost:3000/os/api/ecs/search?search=01.7541914201.0002.18
The following appears in the debug logs:
11:22:11:47 [debug][server] Request received | GET => /os/api/ecs/search?search=01.7541914201.0002.18 | Assigned id: 3ed515d7-b7ef-4593-832d-1bd1ed12479d
11:22:11:47 [debug][server] Sending Not found response | GET => /os/api/ecs/search?search=01.7541914201.0002.18 | 3ed515d7-b7ef-4593-832d-1bd1ed12479d
11:22:11:47 [error][server] Sending Error 'Not Found' | 3ed515d7-b7ef-4593-832d-1bd1ed12479d
I am using the following software versions:
npm: 9.5.0
Node: v18.14.2
If you are missing some information, please let me know.
Thanks for your help and best regards
The text was updated successfully, but these errors were encountered: