lavas-project / lavas

基于 Vue 的 PWA 解决方案,帮助开发者快速搭建 PWA 应用,解决接入 PWA 的各种问题
https://lavas.baidu.com
MIT License
1.97k stars 116 forks source link

关于页面内请求接口问题。盼复。。 #219

Closed shiliangL closed 5 years ago

shiliangL commented 5 years ago

如图page/tags/_id.vue 文件中发送的请求路径会带上 http://localhost:3000/tags/api/playlist/detail?id=5001(多带上了 tags字段,前端代理后台配置如下图)

image

//做了代理 var proxyTable = { // proxy table example '/api': { target: 'http://39.108.65.xxx:3300', changeOrigin: true, pathRewrite: { '^/api': '/' }, } };

PengXing commented 5 years ago

这样看的话,和 proxyTable 没关系吧,前端请求发送出去的时候就带上了 tags,是不是请求 URL 写了相对路径

shiliangL commented 5 years ago

带上 proxyTable 是我猜测可能有关的问题,url 书写的时候是没有 tags 的,然后我在 axios 实例的拦截请求里面打印对应的 url 也是没有 tags 的 所以困惑定位不到问题

PengXing commented 5 years ago

所以,我上面写了啊,你是不是写了相对路径

shiliangL commented 5 years ago

image image 这样的

PengXing commented 5 years ago

你就是写了相对路径,改为 /api

shiliangL commented 5 years ago

好的 感谢 问题以及处理通过了~