These are chat archives for AngularClass/angular2-webpack-starter

13th
Sep 2017
juro
@roland-jungwirth
Sep 13 2017 10:57
Hi, when using the webpack-dev-server, how can I set up proxies that pull their config from a local file?
Stanislav Kovalenko
@KovalenkoStas
Sep 13 2017 12:02
@roland-jungwirth
devServer: {
        contentBase: path.join(__dirname, "dist"),
        compress: true,
        port: 9000,
        proxy: {
            '/api': {
                target: 'http://localhost:3000',
                secure: false,
                pathRewrite: {
                    "^/api": ""
                }
            }
        }
}
juro
@roland-jungwirth
Sep 13 2017 13:39
@KovalenkoStas, thank you. I found that but I needed to pull the actual values from a static (non repo’ed) file. So this is what I did:
var proxies = require("../proxy.config.json");
var proxy_url = proxies.base_api_url;
...
devServer: {
      proxy: {
          '/api_request': {
              target: proxy_url,
              secure: false
          }
      }
    },