我们正在使用Vue.js和Apollo Client构建SPA。我们正在与赛普拉斯一起测试我们的App。看到每个graphQL请求有3秒的延迟,这真的很高兴,只是为了测试一切是否仍按预期工作。
当vue使用http-proxy-middleware时,我尝试向vue.config.js添加一些选项。如下:
module.exports = {
devServer: {
port: 8083,
proxy: {
'^/graphql': {
target: 'http://localhost:8082',
ws: true,
changeOrigin: true,
pathRewrite: async function (path, req) {
console.log("pathRewrite waiting")
await new Promise(resolve => setTimeout(resolve, 3000));
console.log("pathRewrite resolved")
return path;
}
}
}
},
该函数被调用,但是它不会暂停请求。我可以在终端上看到3条延迟的两个日志语句。但是在我的浏览器中,网络请求已经在几毫秒内完成了。
如何在不使用浏览器限制的情况下模拟慢速网络。我不希望浏览器受到限制,因为这是一个手动过程。
什么是最佳做法?配置vue代理?配置阿波罗客户端?还是应该以某种方式在Spring Boot后端触发它?