We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
我想在访问 http://localhost/api/client/xxx 的时候,代理到 http://10.1.44.95:8080/sz/api/,所以我写了如下配置:
http://localhost/api/client/xxx
http://10.1.44.95:8080/sz/api/
/* eslint-disable */ const delay = require('mocker-api/utils/delay'); const proxy = { _proxy: { proxy: { '/api/client/(.*)': 'http://10.1.44.95:8080/sz/api/' }, changeHost: true, }, }; module.exports=delay(proxy, 0);
但是在请求的时候还是会把/api/client带过去
/api/client
$ curl http://localhost:3721/api/client/12 {"timestamp":1576654898376,"status":404,"error":"Not Found","message":"Not Found","path":"/sz/api/api/client/12"}
我想要的效果是访问 http://localhost:3721/api/client/12, 就代理到 /sz/api/12
http://localhost:3721/api/client/12
/sz/api/12
看到 webpack 里面可以用 pathRewrite,单独使用没有找到设置方法
试了好多配置,貌似没有效果啊。。
The text was updated successfully, but these errors were encountered:
feat: Add pathRewrite options. #62
db5a774
released v1.10.0 #62
b244a4d
@zhang0ZGC + mocker-api@1.10.0 现在支持类似 webpack 类似的参数设置 pathRewrite
+ mocker-api@1.10.0
webpack
pathRewrite
{ proxy: { '/api/repos/(.*)': 'http://127.0.0.1:3721/' }, pathRewrite: { '^/api/repos/': '/repos/', }, }
Sorry, something went wrong.
万分感谢 😄
No branches or pull requests
我想在访问
http://localhost/api/client/xxx
的时候,代理到http://10.1.44.95:8080/sz/api/
,所以我写了如下配置:但是在请求的时候还是会把
/api/client
带过去我想要的效果是访问
http://localhost:3721/api/client/12
, 就代理到/sz/api/12
看到 webpack 里面可以用 pathRewrite,单独使用没有找到设置方法
试了好多配置,貌似没有效果啊。。
The text was updated successfully, but these errors were encountered: