I am struggling with webpack dev server proxy. I am using webpack 5.
The goal is to have webpack dev server with local Apache api (PHP/Laravel). Webpack dev server has this settings:
devServer: {
host: 'localhost',
port: 8080,
hot: true,
firewall: false,
public: 'http://dummy.com',
proxy: {
'/admin': 'http://dummy.com',
'/api': 'http://dummy.com',
"changeOrigin": true,
"secure": false,
},
}
I want to be able to access API on dummy.com via proxy. But it is not working. It always ends up on http://localhost.
Windows 10 hosts file:
127.0.0.1 dummy.com
Apache virtual hosts:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "e:\www\TEST\public"
ServerName dummy.com
ErrorLog logs/localhost
CustomLog logs/localhost-access_log common
<Directory "e:\www\TEST\public">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Webpack dev server works fine, but the proxy doesn't. No matter what domain I put into the target, it always proxies to http://localhost. What am I doing wrong? It looks like Apache doesn't receive the request headers and the proxy calls the IP directly.
Thanks for any help!