Open watadarkstar opened 5 years ago
Hi @watadarkstar, pretty sure this is in the docs: https://github.com/typicode/json-server#add-custom-routes :)
@tinavanschelt Hmmm that works if you want to run json-server
from the command line but I'm not sure how to get custom routes to work as an npm module:
I thought maybe this section could be it but I don't think so? https://github.com/typicode/json-server#custom-routes-example
In that case we're probably working on a similar issue. I'm actually just trying to debug a old-ish express integration that used to work (https://github.com/tinavanschelt/redux-starter-with-api/blob/master/server.js) - think it broke during a recent upgrading of packages.
This might help? https://github.com/typicode/json-server/issues/237#issuecomment-465322762
If not, it's probably a case of the blind leading the blind here ☺️ - just thought your answer might be in the docs.
@tinavanschelt This is exactly what I'm looking for!
const routes = require('./routes.json')
...
server.use(jsonServer.rewriter(routes))
Thank you!
Is it possible to run
json-server
such that it responds to/api/posts
rather than/posts
?I want to bring this issue back up from the grave because we need it for some use cases for deploying APIs alongside the same domain as a static site: https://github.com/zeit/now-examples/tree/master/json-server
I'd like to work on this feature if it doesn't exist already.