1. I read the configuration instructions of webpack, but I don"t know how to use
2. This is what I tried in index.
"use strict"
// Template version: 1.2.3
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require("path")
var express = require("express")
var app = express()
var axios = require("axios")
var apiRoutes = express.Router()
module.exports = {
dev: {
// Paths
assetsSubDirectory: "static",
assetsPublicPath: "/",
proxyTable: { //
"/api": {
target: "https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg",
changeOrigin: true,
pathRewrite: {
"^/api": ""
}
}
},
// Various Dev Server settings
host: "localhost", // can be overwritten by process.env.HOST
port: 8085, // can be overwritten by process.env.HOST, if port is in use, a free one will be determined
autoOpenBrowser: true,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/-sharpdevserver-watchoptions-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/-sharpdevelopment
devtool: "eval-source-map",
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html-sharpcachebusting
cacheBusting: true,
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader-sharpsourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false,
before(apiRoutes) {
apiRoutes.get("/lyric", function (req, res) {
var url = "https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg"
axios.get(url, {
headers: {
referer: "https://c.y.qq.com/",
host: "c.y.qq.com"
},
params: req.query
}).then((response) => {
var ret = response.data
if (typeof ret === "string") {
/* \w: */
var reg = /^\w+\(({[^()]+})\)$/ /*==> MusicJsonCallback({\"retcode\":0,\"code\":0,\"subcode\...."})*/
var matches = ret.match(reg)
if (matches) {
ret = JSON.parse(matches[1])
}
}
res.json(ret)
}).catch((e) => {
console.log(e)
})
})
},
after(apiRoutes){
apiRoutes.get("/lyric", function (req, res) {
var url = "https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg"
axios.get(url, {
headers: {
referer: "https://c.y.qq.com/",
host: "c.y.qq.com"
},
params: req.query
}).then((response) => {
var ret = response.data
if (typeof ret === "string") {
/* \w: */
var reg = /^\w+\(({[^()]+})\)$/ /*==> MusicJsonCallback({\"retcode\":0,\"code\":0,\"subcode\...."})*/
var matches = ret.match(reg)
if (matches) {
ret = JSON.parse(matches[1])
}
}
res.json(ret)
console.log(res.json(ret))
}).catch((e) => {
console.log(e)
})
})
}
},
3,
export function getLyric(mid) {
const url = "/api/lyric"
const data = Object.assign({}, commonParams, {
g_tk: 5381,
songmid: mid,
platform: "yqq",
hostUin: 0,
needNewCode: 0,
categoryId: 10000000,
pcachetime: +new Date(),
format: "json"
})
return axios.get(url, {
params: data
}).then((res) => {
return Promise.resolve(res.data)
})
}
4. Destination address not found
5 afterbefore,proxy,Please help me! Thanks very much!