Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能将线上的请求拦截吗 #36

Closed
IEfucker opened this issue Apr 3, 2019 · 6 comments
Closed

能将线上的请求拦截吗 #36

IEfucker opened this issue Apr 3, 2019 · 6 comments

Comments

@IEfucker
Copy link

IEfucker commented Apr 3, 2019

对于本地的请求能拦截,返回mock数据
对于线上地址,比如http://www.baidu.com/api/xxx/test
这样的接口不能使用mock代理吗

@jaywcjlove
Copy link
Owner

@IEfucker 你可能对代理有误解。

@IEfucker
Copy link
Author

IEfucker commented Apr 3, 2019

@jaywcjlove 啊,那我这样做不行喽?

@jaywcjlove
Copy link
Owner

@IEfucker 可以的,你可以运行下面这个例子。试一试。

_proxy: {
proxy: {
'/repos/*': 'https://api.github.com/',
},
changeHost: true,
},

@IEfucker
Copy link
Author

IEfucker commented Apr 3, 2019

抱歉我好像没有把我的问题表述清楚
我遇到一个问题,请求的接口用localhost(当然这个接口在本地也是通过代理,代理到真实地址)可以使用mock拦截,返回mock数据
但我使用真是接口 http://www.baidu.com/api/xxx/test 这种,为什么mock拦截不到

不知道是我配置错了,还是说mockapi只能用在localhost接口?

@jaywcjlove
Copy link
Owner

@IEfucker 你对代理可能有误解,你直接访问API http://www.baidu.com/api/xxx/test 浏览器直接访问百度API,没有走你本地服务,mocker-api 不是一个浏览器插件,它是你本地服务的中间件。

@IEfucker
Copy link
Author

IEfucker commented Apr 3, 2019

哦傻逼了
谢谢解答

@IEfucker IEfucker closed this as completed Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants