Webpack setting reverse proxy is invalid

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

Mar.23,2021

http://baidu.com/car/car-list will appear 302ah
you can try

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

check whether the http status code is 200

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eae273-21b6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eae273-21b6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?