Repository navigation
Replies: 3 comments
|
Since Vite 6.0.9+, 5.4.12+, 4.5.6+, you need to set |
|
This is Vite host-check protection. If Railway is reaching the Vite server with host If you are running // vite.config.ts
import { defineConfig } from "vite"
export default defineConfig({
preview: {
allowedHosts: ["app"],
},
})If you are running the dev server ( export default defineConfig({
server: {
allowedHosts: ["app"],
},
})I would avoid Also note that Docs:
|
|
TL;DR — Newer Vite is stricter about the Fix (dev) — in export default defineConfig({
server: {
host: true,
allowedHosts: ['app', '.railway.app'], // adjust to your real hostnames
},
})Fix (preview — matches your error text) — same idea under preview: {
allowedHosts: ['app', '.railway.app'],
},What to put in Production note — on Railway you usually serve the built assets with a static server or adapter, not After changing config, restart the dev server. If it still blocks, paste the exact |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
I updated Vite to latest now I'm starting to have this, then i downgraded but still same thing, what is happening?
Blocked request. This host ("app") is not allowed.
To allow this host, add "app" to
preview.allowedHostsin vite.config.js.I use Railway as hosting and i have no idea how to fix this?
Reproduction
https://github.com/MariuzM/frameworks/tree/main/react-tsr
Steps to reproduce
No response
System Info
System: OS: macOS 14.7.2 CPU: (10) arm64 Apple M1 Max Memory: 24.44 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.17.0 - ~/dev/node-v20.17.0/bin/node Yarn: 1.22.22 - ~/dev/node-v20.17.0/bin/yarn npm: 10.8.2 - ~/dev/node-v20.17.0/bin/npm pnpm: 9.12.2 - ~/Library/pnpm/pnpm bun: 1.2.2 - ~/.bun/bin/bun Browsers: Brave Browser: 133.1.75.175 Chrome: 130.0.6723.70 Safari: 18.2Used Package Manager
bun
Logs
No response
Validations
All reactions