Since Vite 6.0.9+, 5.4.12+, 4.5.6+, you need to set preview.allowedHost if you are accessing the server with a host name other than localhost.
https://github.com/vitejs/vite/discussions/19426