加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

vue 新版本 webpack 代理 跨域设置

发布时间:2020-12-16 23:14:24 所属栏目:百科 来源:网络整理
导读:旧版本中:dev-server.js 这段去掉 apiRoutes = apiRoutes.get('/getDiscList', url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg' 'https://c.y.qq.com/' 'c.y.qq.com' => ((e) => apiRoutes.get('/lyric',res) { url = 'https://c.y.

旧版本中:dev-server.js 这段去掉

apiRoutes = apiRoutes.get('/getDiscList', url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg''https://c.y.qq.com/''c.y.qq.com'=>((e) => apiRoutes.get('/lyric',res) { url = 'https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg'axios.get(url,params: req.query
}).then((response)
=><span style="color: #000000"> {
<span style="color: #0000ff">var
ret =<span style="color: #000000"> response.data
<span style="color: #0000ff">if
(<span style="color: #0000ff">typeof
ret === 'string'<span style="color: #000000">) {
<span style="color: #0000ff">var
reg = /^w+(({[^()]+}))$/
<span style="color: #0000ff">var
matches =<span style="color: #000000"> ret.match(reg)
<span style="color: #0000ff">if
<span style="color: #000000"> (matches) {
ret
= JSON.parse(matches[1<span style="color: #000000">])
}
}
res.json(ret)
}).
<span style="color: #0000ff">catch
((e) =><span style="color: #000000"> {
console.log(e)
})
})
<span style="color: #008000">//
<span style="color: #008000">use
app.use('/api',apiRoutes)

在 新的 webpack.dev.config.js 中 添加

const express = require('express'= require('axios'= apiRoutes ='/api'
const devWebpackConfig = 'warning'/.*/,to: path.posix.join(config.dev.assetsPublicPath,'index.html' app.get('/api/getDiscList', url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg''https://c.y.qq.com/''c.y.qq.com'=>((e) => hot: , compress: ||||? { warnings: ,errors: } : , 'process.env': require('../config/dev.env' webpack.NamedModulesPlugin(), 'index.html''index.html' '../static''.*'

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读