Skip to content

How to implement custom routes? #434

Closed
@jedfoster

Description

@jedfoster

I'm trying to figure out how to implement custom routes using json-server's rewriter.

I have tried this:

server.use(jsonServer.rewriter({
  '/blog/:resource/:id/show': '/:resource/:id',
  '/articles?id=:id': '/posts/:id'
}))

let core: CoreApp | undefined;

But I get 404 Not Found from http://localhost:3000/dev/api/blog/posts/1/show (I'm using the example JSON from the json-server readme) http://localhost:3000/dev/api/posts/1 works just fine.

What am I doing wrong?


On a related note, it would be nice if the api/ path could be configured from appconfig.json. I may put in a PR for that change.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions