鍍金池/ 問答/HTML/ vuejs打包跨域的應(yīng)該怎么設(shè)置?

vuejs打包跨域的應(yīng)該怎么設(shè)置?

打包后出現(xiàn)了 跨域請求路徑報錯

clipboard.png
應(yīng)該在哪里設(shè)置路徑?
config/index代碼:
dev: {

// Paths
assetsSubDirectory: 'static',
assetsPublicPath: './',
proxyTable: {
  "/api":{
  target:"https://www.qqbsmall.com",
  changeOrigin:true,
  pathRewrite:{
    "^/api":""
  }
}},


build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),

// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',


要是想先到本地運行打包后的文件  又要怎么設(shè)置?
回答
編輯回答
款爺

上線之后的跨域讓服務(wù)端(設(shè)置cors或者設(shè)置代理)去搞。開發(fā)的時候是本地起了一個node服務(wù)給你代理了。

2017年11月21日 06:05
編輯回答
櫻花霓

你這個開發(fā)的時候用了dev環(huán)境中的代理,你打包了,要放到服務(wù)環(huán)境才行,就是那target對應(yīng)的web服務(wù)器,直接雙擊html文件是不行的

2018年2月19日 00:35