admin管理员组文章数量:1442602
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.allowedHosts` in 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]
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.allowedHosts` in 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]
- I had this pop up today as well, and saw your question. Seems like some recent releases are relevant to the server.allowedHosts feature: github.com/vitejs/vite/commit/… I rolled back to version 6.0.6 which gets my application back up and running. This doesn't "fix" the issue technically, but perhaps more information will come out soon on how to properly set this up in newer versions. – RealDealNeill Commented Jan 21 at 2:31
- Thanks for the answer! It turned out that the dockerfile specified the line ``` RUN npm install -g vite``` without specifying the version, so the latest release was installed, which broke the application. I installed the version below – twentyxic Commented Jan 21 at 6:11
1 Answer
Reset to default 8A 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'],
}
本文标签: reactjsBlocked request This host (quotfrontendwebquot) is not allowedStack Overflow
版权声明:本文标题:reactjs - Blocked request. This host ("frontend_web") is not allowed - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738672681a2106087.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论