vue 新版本 webpack 代理 跨域设置

旧版本中: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''.*'

相关文章

https://segmentfault.com/a/1190000022018995 https://www....
ES6 (ECMAScript 6)中的模块是一个包含 JavaScript 代码的...
from https://mp.weixin.qq.com/s/-rc1lYYlsfx-wR4mQmIIQQ V...
D:\Temp&gt;npm init vite@latest vue3study --temp...
文章浏览阅读1.2k次。最近自己从零撸起的甘特图组件需要子组...
文章浏览阅读3.3k次,点赞3次,收藏16次。静默打印是什么?简...