When building vite react in docker-compose application, a message appears when opening the web-site page
Blocked request. This host ("frontend_web") is not allowed. To allow this host, add "frontend_web" to
server.allowedHostsin vite.config.js.
I tried to use vite-plugin-allowed-hosts but it gives me an error when building the docker-container
[ERROR] Failed to resolve entry for package "vite-plugin-allowed-hosts". The package may have incorrect main/module/exports specified in its package.json. [plugin externalize-deps]
A recent Vite update (6.0.11, to my knowledge) has introduced changes that "break" setups using proxies. To resolve this, you need to configure allowedHosts in your Vite configuration as told.
In your case this should work:
server: {
allowedHosts: ['frontend_web'],
}
or
server: {
allowedHosts: true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With