jsonServer.rewriter not work in module solution
See original GitHub issueMy main code is very simple as below,
/// Set default middlewares (logger, static, cors and no-cache)
server.use(middlewares);
// To handle POST, PUT and PATCH you need to use a body-parser
// You can use the one used by JSON Server
server.use(jsonServer.bodyParser);
// Use default router
// server.use(jsonServer.rewriter({
// '/api/v1/': '/'
// }));
server.use('/api/v1', router);
server.listen(3000, () => {
console.log('JSON Server is running')
});
neither rewriter nor server.use('/api/v1', router)
worked, the access url only happened on /
not /api/v1/...
any idea?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
jsonserver not redirecting using rewriter - Stack Overflow
If i start the server using "node server" then it starts the json server and also supports rewriting. However if use npx json-server...
Read more >typicode/json-server - Gitter
i.e. I'm trying to do something like below in routes.js but only for a GET request on an endpoint, let's say GET /clients...
Read more >3 ways to mock an API in JavaScript | Where those can help you
So, my suggestion is creating a structure and use json-server as module and not as command line directly. Copy. # node ApiMock/server OR...
Read more >How to use the json-server.defaults function in json-server | Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks it finally worked. Hopefully document could get improved
@qiluo Hello, maybe you can close this issue ?