-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[vite 6.0.9] option server.allowedHosts doesn't take into account "true" #19242
Comments
This comment has been minimized.
This comment has been minimized.
Yes, same issue coming to me as well when I am trying below config in my vite config file (vite.config.ts). Please fix it.
|
https://vite.dev/config/server-options#server-allowedhosts Tried to follow the same procedure but not working.. Blocked request. This host ("hostname") is not allowed. |
I wasn't able to reproduce it with a simple setup. I need a reproduction to investigate this one. |
Hello @Reaster0. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
Also encountering this after pushing an update today, no changes to vite config |
I resolved this by updating vite.config - what's odd here is that I had not upgraded to 6+ and the error just presented overnight. export default defineConfig({
plugins: [sveltekit()],
server: {
cors: {
origin: ['https://mysubdomain.domain.io', 'http://localhost:5173'],
methods: ['GET', 'POST'],
allowedHeaders: ['Content-Type']
},
allowedHosts: ['mysubdomain.domain.io'] //added this
}
}); |
The problem still exists in 6.0.11. Downgrading to 6.0.8 makes it work. |
Hm... please take a look into tools that use vite to run. For example I have same issue with vite + storybook, because of storybook. I defined in storybook config the server options: import {mergeConfig} from 'vite';
// ...
async viteFinal(config) {
return mergeConfig(config, {
server: {
hmr: {
path: '/ws'
}
}
});
}, and the problem is that mergeConfig will replace |
Mine is just a plain Vite project with React. Nothing else. |
i'm not sure i have the time rn to make a replication for something this simple, in the mean time i've rollbacked to 6.0.8 it's really a breaking issue for a lot of people, changing the default allowedHost from 0.0.0.0 to localhost and having a bug on the same field to set back to 0.0.0.0 will break a lot of vite installations, |
yes you can set the hosts you want in allowedHosts, the bug we encounter specifically is when setting allowedHosts to "true" |
I've tried it again but still cannot reproduce. I need a reproduction. |
Understood, I also tried I am now using 6.0.10 so can only speak to that version. |
Also happening for latest 4.x.x version. Downgrading to |
This comment has been minimized.
This comment has been minimized.
Caution Please note that downgrading will make you vulnerable to attacks described in GHSA-vg6x-rcgg-rjx6. |
This comment has been minimized.
This comment has been minimized.
No, those are not the only choices. |
Blocked request. This host ("myhost.com") is not allowed.
|
This comment has been minimized.
This comment has been minimized.
putting all the settings in the server block worked for allowedHosts: true or ['dev.mydomain.com'] no problem with "npm run dev" I was accessing my dev server from outside network domain name. I configured my router to forward port 8080 to the dev server. It would error without the setting. import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' // https://vite.dev/config/ |
@sapphi-red could it be fair to say the issue was introduced here? bd896fb With more time happy to help debug and reproduce, but trying to keep this moving |
@gregorvand That commit is the one that introduced |
Thanks @sapphi-red , a couple of things stand out - default for and / or, bd896fb#diff-abb3345b6e3b2ec6d297c2ebc54cca85ae4487a31bac3cc9e78457f5114adb26R864 removing Will hopefully have more time later this week to look more |
I use MedusaJS and have the same issue. // medusa-config.ts
module.exports = defineConfig({
// ...
admin: {
vite: config => {
config.server.allowedHosts = ['my.custom.domain.com']
return config;
}
},
}) |
Yeah, we are using vite: 5.1.3 with React 18 (works for local dev...but when we do deployment on docker image in K8s with nginx proxy we encouter this issue too!!) Ay Karamba! Trying to leave no stone unturned to fix it! |
I had the same issue while developing a Shopify-Remix app and using Ngrok as a tunnel. At first everything was working fine and suddenly it stopped working and vite was blocking all Ngrok requests even though it was added in After some debugging and trying to run vite separately using And indeed there was something already running on port 3000. The issue went away after that. I suggest running vite on the project to check for any errors
Hope this helps someone ✌ |
Weirdly enough, I don't have this issue on my Linux machine, but I have it on the Mac. Here on the Mac, only |
Update: I spotted the error on my project. Basically, I'm visiting the application using a custom local domain that is not Thing is, I don't have this error on the Linux machine. Only here on the Mac. TL;DR If you're using a custom local domain, try to start the Vite dev server with the Update 2: Even more surprisingly, I was able to fix the issue on OSX without setting
|
I don't understand why this was closed. I'm finding myself reverting to 6.0.8 to resolve this issue. |
@CollinHerber it was closed because nobody provided a minimal reproduction. Please create a new issue following the issue template. |
@patak-dev what form of minimal reproduction is sufficient here? When the issue seems to lie with deploying to infra vs local environment |
You can kinda mimic this by using ngrok and using the link that it provides. The link will be blocked because allowedHosts is ignored. |
@gregorvand I'm fine with a reproduction using docker (+ docker-compose). You can also provide a bigger reproduction. Then, I can ask you trimming down the unrelated stuff. @CollinHerber Please create an issue with minimal reproduction (without storybook). If it only reproduces with storybook, then it can be due to storybook instead, so please report there first. |
Hi @sapphi-red, I've made an issue with some reproduction steps which I hope assist you: #19411 This is definitely not a storybook issue. Because I see the problem in a Docker context, and it involves routing configuration, I wasn't able to do a |
Jezus what a complete mess sorry but how was this release to prod when its just breaking for everyone? |
I reverted back to 6.0.9 (down from 6.1.0) in docker (build on a mac m1) and it is still not working. |
The issue appeared in 6.0.9. Try 6.0.8. That worked for me until we get this figured out. |
Sorry I made a typo - I tried 6.0.8 - and it was still there |
Same here with Astro. Using Docker and jwilders nginx reverse proxy.
but, if i add it to server.allowedHosts - same as before... it tried Vite version 6.0.11 |
Same issue when running:
on a I'm on a macbook air m1 chip from 2020. No resolution and blocked if using 6.0.9, 6.1.0 and 6.1.1. Downgraded to 6.0.8 and it is now resolved. |
Thank you, @mdesantis ! Setting the |
In Astro.js i have found the solution. Just add the "vite" property to the config and place all the server config under this property. Then it works. Its not documented. |
@seekwhencer do you have an example? i don't really get what you're saying |
@sapphi-red @bluwy @patak-dev do you have an idea on this still active issue? thanks |
@Reaster0 this issue was closed because there was no minimal reproduction. You linked to |
it's really only a basic config with in vite.config.js the option server.allowedHosts=true |
FIXED (at least for me) so i was making a git for reproduction, a basic vite + react project, + custom domain in the hosts file
yes, in the final stage i miss the vite.config.ts file,
because even if all of the other values are used during the build stage, the "server" is used when invoking the vite server, so he don't have it, right? so the issue was: @patak-dev @sapphi-red you can tell me "told you, can't reproduce" :') |
I resolved the issue by NOT using |
Describe the bug
hi, i've recently updated vite to 6.0.9, the main change being the allowedHosts server conf field,
it's said in the documentation that if set to true, it will accept any hosts, but even when setting it to true i get the error:
Blocked request. This host ("hidden") is not allowed.
To allow this host, add "hidden" to
server.allowedHosts
in vite.config.js.(maybe i could be dumb but it really doesn't seem to work)
Reproduction
google.com
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: