VUE的跨域(端口)问题
场景:vue启动需要一个端口,服务端启动需要一个端口,需要让vue应用访问服务器的端口'use strict'// Template version: 1.3.1// see http://vuejs-templates.github.io/webpack for documentation.const path = require('path');module.exports = {...
·
场景:vue启动需要一个端口,服务端启动需要一个端口,需要让vue应用访问服务器的端口
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path');
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 8081, // vue启动端口
autoOpenBrowser: true,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
proxyTable: {
'/api': {
target: 'http://localhost:8080',//vue访问后台服务的端口
changeOrigin: true,
pathRewrite: {
'^/api': '/api'
}
}
},
devtool: 'cheap-module-eval-source-map',
cacheBusting: true,
cssSourceMap: true
},
build: {
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
productionSourceMap: true,
devtool: '#source-map',
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
bundleAnalyzerReport: process.env.npm_config_report
}
}
'^/api': '/api' 改为 '^/api': '' 成功了
更多推荐
已为社区贡献1条内容
所有评论(0)