I'm trying to use json-server
with custom routes, but they're all returning a 404.I can see that the routes.json
file is being read, as well as the db.json
file.
Here's the output from running json-server:
Resources
http://localhost:8000/check
http://localhost:8000/custom-route
Other routes
/custom-route/me/ -> /custom-route
Home
http://localhost:8000
GET /check 304 2.994 ms - -
GET /custom-route/me/ 404 2.363 ms - 2
As you can see, json-server understands the custom route but it's not translating it. In the case of /custom-route/me
, all I want is for it to end up in the same path, just without the /me
.
Here's routes.json
:
{
"/custom-route/me/": "/custom-route"
}
And here's the part of db.json
that refers to /custom-route
:
"custom-route": {
"response": "check"
},
What's going on and how can I fix it?