D
D
dariadzel2019-11-25 14:51:54
JavaScript
dariadzel, 2019-11-25 14:51:54

Why doesn't proxy work in Webpack's devServer?

I'm trying to set up a dev build so that it sends and receives data from the prod server through a proxy in the Webpack dev server.
In the target key, I specify the address to which the proxy should replace requests to the server, but as a result, requests still go to the address of my localhost, which causes a 500 error to appear in the console. I can't figure out where the error is in the config file:

devServer: {
        contentBase: commonWebpack.externals.path.src,
        watchContentBase: true,
        port: 8080,
        open: true,
        hot: true,
        proxy: {
            '/': {
                target: 'http://mysite.ru',
                changeOrigin: true
            }
        }
    },

Webpack version 4.39.3, http-proxy-middleware version 0.20.0.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dariadzel, 2019-11-26
@dariadzel

I close the question, because the problem turned out to be not in the proxy settings, but in the specifics of processing requests on the server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question