简体   繁体   English

如何在JSON服务器中设置本地路由

[英]How to set home route in json-server

How can I set home route in json-server to be "/api" instead of "/" ? 如何在json-server中将本地路由设置为"/api"而不是"/" I tried this: 我尝试了这个:

server.use(jsonServer.rewriter({
  "/api/": "/"
}));

but, it does not work 但是,它不起作用

With "/api/*": "/$1" you should match the route / . 使用"/api/*": "/$1"您应该将路由/匹配。

See https://github.com/typicode/json-server#add-custom-routes . 参见https://github.com/typicode/json-server#add-custom-routes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM