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

vite-plugin-mock 和vite的proxy同时开启问题 #63

Closed
unforesndprson opened this issue Oct 27, 2020 · 13 comments
Closed

vite-plugin-mock 和vite的proxy同时开启问题 #63

unforesndprson opened this issue Oct 27, 2020 · 13 comments

Comments

@unforesndprson
Copy link

vite-plugin-mock 的mock数据如果不存在的话,接口会一直处于pending状态,vite的proxy不起作用

@anncwb
Copy link
Collaborator

anncwb commented Oct 27, 2020

能提供下复现步骤或者测试接口吗,我这边正常

@unforesndprson
Copy link
Author

我是直接把mock/sys/user.ts的/api/login数据注释,登录时/api/login会一直pending直到超时

@anncwb
Copy link
Collaborator

anncwb commented Oct 28, 2020

登录注释后代理到后台是吗?可以提供下截图或者更详细的信息?

@anncwb
Copy link
Collaborator

anncwb commented Oct 28, 2020

尝试先将 /src/utils/http/axios/index.ts 内 的beforeRequestHook函数里面的所有config.params={}改成config.params=undefined

@unforesndprson
Copy link
Author

1.config.params=>undefined
undefined
2.设置代理地址 期待https://getman.cn/mock/login返回{test:1}
env

@anncwb
Copy link
Collaborator

anncwb commented Oct 28, 2020

我测试看看

@anncwb
Copy link
Collaborator

anncwb commented Oct 28, 2020

这个接口是get,登录是post

@unforesndprson
Copy link
Author

临时找了个模拟接口的地址,post应该也是可以的吧。
但不管代不代理,我这边测试找不到mock数据时,接口会一直pending
login

@anncwb
Copy link
Collaborator

anncwb commented Oct 28, 2020

文档有这个问题。proxy代理https还有问题。刚看是https接口

@unforesndprson
Copy link
Author

咦 有点不明白,我本地关掉 VITE_USE_MOCK,代理https是没问题的
然后我想实现的是 如何在使用vite-plugin-mock的时候,用proxy代理那些mock没有配置的接口,不管proxy代理的是http或https

@anncwb
Copy link
Collaborator

anncwb commented Oct 28, 2020

我再注意下这个问题

@anncwb
Copy link
Collaborator

anncwb commented Oct 28, 2020

已找到原因,是因为vite-plugin-mock我用了bodyparse导致的。下一版修复

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