在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ webpack 設(shè)置反向代理無效

webpack 設(shè)置反向代理無效

webpack.dev.conf.js

const path = require('path'),
  webpack = require('webpack'),
  UglifyJSPlugin = require("uglifyjs-webpack-plugin"),
  HtmlWebpackPlugin = require("html-webpack-plugin"),
  config = require('./webpack.base.conf.js');

config.devServer = {
  port: '9500',
  host: 'localhost',
  historyApiFallback: true,
  watchOptions: {
    aggregateTimeout: 300,
    poll: 1000
  },
  contentBase: path.join(__dirname, '../dist'),
  // hot: true,
  proxy: {
    '/api': {
      target: 'http://baidu.com',
      secure: false,
      changeOrigin: true,
      pathRewrite: {
        "^/api": ""
      }
    }
  }
}

config.plugins = (config.plugins || []).concat([
  // new webpack.HotModuleReplacementPlugin(),
  new webpack.NamedModulesPlugin(),
  new HtmlWebpackPlugin({
    title: 'CMS-FE DEV',
    filename: 'index.html',
    template: 'src/template/index_base.html',
    // template: 'dist/index.html',
  })
]);

module.exports = config;

  public getCarList (data: any) {
      return this.http.get(`/api/car/car-list`, {
      params: data,
    });
    // return this.carList;
  }
  }

clipboard.png

回答
編輯回答
故人嘆

http://baidu.com/car/car-list 就是會(huì)出現(xiàn)302啊
可以試一下

this.http.get(`/api/s`, {
    params: {
        wd: 'test'
    }
});

看看http狀態(tài)碼是不是200

2017年7月28日 00:45