How to get webpack and iis express to work together?

后端 未结 4 1911
傲寒
傲寒 2021-02-20 07:12

I have Angular 2 and Webpack 2 starter which run on node by webpack-dev-server, and I what to run it from visual studio with web-api.

The problem is when angular2-webpa

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-20 07:46

    I had the same dilemma and solved it just by using the proxy option in the webpack dev server config:

    module.exports = {
        devServer: {
            contentBase: './dist', /* output folder */
            proxy: {
                '/api': {                                 /* I had only to track calls to api, change path to one you need*/
                    target: 'http://localhost:15536/'     /* specify your correct IIS port here */
                }
            }
        },
    /*other configurations here*/
    }
    

    After code is in place, just run the VS project and start WebPack Dev server alongside. Now all the calls from the app will be redirected to your ASP.NET server.

    Let me know if any questions.

提交回复
热议问题