Skip to content
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

fix: preview.allowedHosts with specific values was not respected #19246

Merged

Conversation

sapphi-red
Copy link
Member

Description

Setting preview.allowedHosts: ['example.com'] was not respected. The workaround would be to set it to server.allowedHosts instead.

@sapphi-red sapphi-red added has workaround p3-minor-bug An edge case that only affects very specific usage (priority) labels Jan 21, 2025
@sapphi-red sapphi-red merged commit aeb3ec8 into vitejs:main Jan 21, 2025
15 checks passed
@sapphi-red sapphi-red deleted the fix/preview-allowed-hosts-specific-value branch January 21, 2025 07:47
@sunilranaLivspace
Copy link

Description

Setting preview.allowedHosts: ['example.com'] was not respected. The workaround would be to set it to server.allowedHosts instead.

Hi @sapphi-red,

vite preview is used for production builds, while the vite server configuration is intended to customize and enhance the local development environment.

If I need to deploy my build to production, would setting server.allowedHosts be a valid workaround, or would it still apply in the production environment?

@sapphi-red
Copy link
Member Author

@sunilranaLivspace This PR is already released in 6.0.11, 5.4.14, 4.5.9 so you won't need to apply a workaround.
As long as you don't use the preview server (vite preview) for deployment (which is discouraged), the settings in server.allowedHosts/preview.allowedHosts does not matter.

renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Jan 24, 2025
| datasource | package | from  | to     |
| ---------- | ------- | ----- | ------ |
| npm        | vite    | 6.0.7 | 6.0.11 |


## [v6.0.11](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6011-2025-01-21-small)

-   fix: `preview.allowedHosts` with specific values was not respected ([#19246](vitejs/vite#19246)) ([aeb3ec8](vitejs/vite@aeb3ec8)), closes [#19246](vitejs/vite#19246)
-   fix: allow CORS from loopback addresses by default ([#19249](vitejs/vite#19249)) ([3d03899](vitejs/vite@3d03899)), closes [#19249](vitejs/vite#19249)


## [v6.0.10](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6010-2025-01-20-small)

-   fix: try parse `server.origin` URL ([#19241](vitejs/vite#19241)) ([2495022](vitejs/vite@2495022)), closes [#19241](vitejs/vite#19241)


## [v6.0.9](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small609-2025-01-20-small)

-   fix!: check host header to prevent DNS rebinding attacks and introduce `server.allowedHosts` ([bd896fb](vitejs/vite@bd896fb))
-   fix!: default `server.cors: false` to disallow fetching from untrusted origins ([b09572a](vitejs/vite@b09572a))
-   fix: verify token for HMR WebSocket connection ([029dcd6](vitejs/vite@029dcd6))


## [v6.0.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small608-2025-01-20-small)

-   fix: avoid SSR HMR for HTML files ([#19193](vitejs/vite#19193)) ([3bd55bc](vitejs/vite@3bd55bc)), closes [#19193](vitejs/vite#19193)
-   fix: build time display 7m 60s ([#19108](vitejs/vite#19108)) ([cf0d2c8](vitejs/vite@cf0d2c8)), closes [#19108](vitejs/vite#19108)
-   fix: don't resolve URL starting with double slash ([#19059](vitejs/vite#19059)) ([35942cd](vitejs/vite@35942cd)), closes [#19059](vitejs/vite#19059)
-   fix: ensure `server.close()` only called once ([#19204](vitejs/vite#19204)) ([db81c2d](vitejs/vite@db81c2d)), closes [#19204](vitejs/vite#19204)
-   fix: resolve.conditions in ResolvedConfig was `defaultServerConditions` ([#19174](vitejs/vite#19174)) ([ad75c56](vitejs/vite@ad75c56)), closes [#19174](vitejs/vite#19174)
-   fix: tree shake stringified JSON imports ([#19189](vitejs/vite#19189)) ([f2aed62](vitejs/vite@f2aed62)), closes [#19189](vitejs/vite#19189)
-   fix: use shared sigterm callback ([#19203](vitejs/vite#19203)) ([47039f4](vitejs/vite@47039f4)), closes [#19203](vitejs/vite#19203)
-   fix(deps): update all non-major dependencies ([#19098](vitejs/vite#19098)) ([8639538](vitejs/vite@8639538)), closes [#19098](vitejs/vite#19098)
-   fix(optimizer): use correct default install state path for yarn PnP ([#19119](vitejs/vite#19119)) ([e690d8b](vitejs/vite@e690d8b)), closes [#19119](vitejs/vite#19119)
-   fix(types): improve `ESBuildOptions.include / exclude` type to allow `readonly (string | RegExp)[]`  ([ea53e70](vitejs/vite@ea53e70)), closes [#19146](vitejs/vite#19146)
-   chore(deps): update dependency pathe to v2 ([#19139](vitejs/vite#19139)) ([71506f0](vitejs/vite@71506f0)), closes [#19139](vitejs/vite#19139)
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Jan 25, 2025
| datasource | package | from  | to     |
| ---------- | ------- | ----- | ------ |
| npm        | vite    | 6.0.7 | 6.0.11 |


## [v6.0.11](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6011-2025-01-21-small)

-   fix: `preview.allowedHosts` with specific values was not respected ([#19246](vitejs/vite#19246)) ([aeb3ec8](vitejs/vite@aeb3ec8)), closes [#19246](vitejs/vite#19246)
-   fix: allow CORS from loopback addresses by default ([#19249](vitejs/vite#19249)) ([3d03899](vitejs/vite@3d03899)), closes [#19249](vitejs/vite#19249)


## [v6.0.10](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6010-2025-01-20-small)

-   fix: try parse `server.origin` URL ([#19241](vitejs/vite#19241)) ([2495022](vitejs/vite@2495022)), closes [#19241](vitejs/vite#19241)


## [v6.0.9](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small609-2025-01-20-small)

-   fix!: check host header to prevent DNS rebinding attacks and introduce `server.allowedHosts` ([bd896fb](vitejs/vite@bd896fb))
-   fix!: default `server.cors: false` to disallow fetching from untrusted origins ([b09572a](vitejs/vite@b09572a))
-   fix: verify token for HMR WebSocket connection ([029dcd6](vitejs/vite@029dcd6))


## [v6.0.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small608-2025-01-20-small)

-   fix: avoid SSR HMR for HTML files ([#19193](vitejs/vite#19193)) ([3bd55bc](vitejs/vite@3bd55bc)), closes [#19193](vitejs/vite#19193)
-   fix: build time display 7m 60s ([#19108](vitejs/vite#19108)) ([cf0d2c8](vitejs/vite@cf0d2c8)), closes [#19108](vitejs/vite#19108)
-   fix: don't resolve URL starting with double slash ([#19059](vitejs/vite#19059)) ([35942cd](vitejs/vite@35942cd)), closes [#19059](vitejs/vite#19059)
-   fix: ensure `server.close()` only called once ([#19204](vitejs/vite#19204)) ([db81c2d](vitejs/vite@db81c2d)), closes [#19204](vitejs/vite#19204)
-   fix: resolve.conditions in ResolvedConfig was `defaultServerConditions` ([#19174](vitejs/vite#19174)) ([ad75c56](vitejs/vite@ad75c56)), closes [#19174](vitejs/vite#19174)
-   fix: tree shake stringified JSON imports ([#19189](vitejs/vite#19189)) ([f2aed62](vitejs/vite@f2aed62)), closes [#19189](vitejs/vite#19189)
-   fix: use shared sigterm callback ([#19203](vitejs/vite#19203)) ([47039f4](vitejs/vite@47039f4)), closes [#19203](vitejs/vite#19203)
-   fix(deps): update all non-major dependencies ([#19098](vitejs/vite#19098)) ([8639538](vitejs/vite@8639538)), closes [#19098](vitejs/vite#19098)
-   fix(optimizer): use correct default install state path for yarn PnP ([#19119](vitejs/vite#19119)) ([e690d8b](vitejs/vite@e690d8b)), closes [#19119](vitejs/vite#19119)
-   fix(types): improve `ESBuildOptions.include / exclude` type to allow `readonly (string | RegExp)[]`  ([ea53e70](vitejs/vite@ea53e70)), closes [#19146](vitejs/vite#19146)
-   chore(deps): update dependency pathe to v2 ([#19139](vitejs/vite#19139)) ([71506f0](vitejs/vite@71506f0)), closes [#19139](vitejs/vite#19139)
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Jan 26, 2025
| datasource | package | from  | to     |
| ---------- | ------- | ----- | ------ |
| npm        | vite    | 6.0.7 | 6.0.11 |


## [v6.0.11](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6011-2025-01-21-small)

-   fix: `preview.allowedHosts` with specific values was not respected ([#19246](vitejs/vite#19246)) ([aeb3ec8](vitejs/vite@aeb3ec8)), closes [#19246](vitejs/vite#19246)
-   fix: allow CORS from loopback addresses by default ([#19249](vitejs/vite#19249)) ([3d03899](vitejs/vite@3d03899)), closes [#19249](vitejs/vite#19249)


## [v6.0.10](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6010-2025-01-20-small)

-   fix: try parse `server.origin` URL ([#19241](vitejs/vite#19241)) ([2495022](vitejs/vite@2495022)), closes [#19241](vitejs/vite#19241)


## [v6.0.9](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small609-2025-01-20-small)

-   fix!: check host header to prevent DNS rebinding attacks and introduce `server.allowedHosts` ([bd896fb](vitejs/vite@bd896fb))
-   fix!: default `server.cors: false` to disallow fetching from untrusted origins ([b09572a](vitejs/vite@b09572a))
-   fix: verify token for HMR WebSocket connection ([029dcd6](vitejs/vite@029dcd6))


## [v6.0.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small608-2025-01-20-small)

-   fix: avoid SSR HMR for HTML files ([#19193](vitejs/vite#19193)) ([3bd55bc](vitejs/vite@3bd55bc)), closes [#19193](vitejs/vite#19193)
-   fix: build time display 7m 60s ([#19108](vitejs/vite#19108)) ([cf0d2c8](vitejs/vite@cf0d2c8)), closes [#19108](vitejs/vite#19108)
-   fix: don't resolve URL starting with double slash ([#19059](vitejs/vite#19059)) ([35942cd](vitejs/vite@35942cd)), closes [#19059](vitejs/vite#19059)
-   fix: ensure `server.close()` only called once ([#19204](vitejs/vite#19204)) ([db81c2d](vitejs/vite@db81c2d)), closes [#19204](vitejs/vite#19204)
-   fix: resolve.conditions in ResolvedConfig was `defaultServerConditions` ([#19174](vitejs/vite#19174)) ([ad75c56](vitejs/vite@ad75c56)), closes [#19174](vitejs/vite#19174)
-   fix: tree shake stringified JSON imports ([#19189](vitejs/vite#19189)) ([f2aed62](vitejs/vite@f2aed62)), closes [#19189](vitejs/vite#19189)
-   fix: use shared sigterm callback ([#19203](vitejs/vite#19203)) ([47039f4](vitejs/vite@47039f4)), closes [#19203](vitejs/vite#19203)
-   fix(deps): update all non-major dependencies ([#19098](vitejs/vite#19098)) ([8639538](vitejs/vite@8639538)), closes [#19098](vitejs/vite#19098)
-   fix(optimizer): use correct default install state path for yarn PnP ([#19119](vitejs/vite#19119)) ([e690d8b](vitejs/vite@e690d8b)), closes [#19119](vitejs/vite#19119)
-   fix(types): improve `ESBuildOptions.include / exclude` type to allow `readonly (string | RegExp)[]`  ([ea53e70](vitejs/vite@ea53e70)), closes [#19146](vitejs/vite#19146)
-   chore(deps): update dependency pathe to v2 ([#19139](vitejs/vite#19139)) ([71506f0](vitejs/vite@71506f0)), closes [#19139](vitejs/vite#19139)
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Jan 27, 2025
| datasource | package | from  | to     |
| ---------- | ------- | ----- | ------ |
| npm        | vite    | 6.0.7 | 6.0.11 |


## [v6.0.11](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6011-2025-01-21-small)

-   fix: `preview.allowedHosts` with specific values was not respected ([#19246](vitejs/vite#19246)) ([aeb3ec8](vitejs/vite@aeb3ec8)), closes [#19246](vitejs/vite#19246)
-   fix: allow CORS from loopback addresses by default ([#19249](vitejs/vite#19249)) ([3d03899](vitejs/vite@3d03899)), closes [#19249](vitejs/vite#19249)


## [v6.0.10](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6010-2025-01-20-small)

-   fix: try parse `server.origin` URL ([#19241](vitejs/vite#19241)) ([2495022](vitejs/vite@2495022)), closes [#19241](vitejs/vite#19241)


## [v6.0.9](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small609-2025-01-20-small)

-   fix!: check host header to prevent DNS rebinding attacks and introduce `server.allowedHosts` ([bd896fb](vitejs/vite@bd896fb))
-   fix!: default `server.cors: false` to disallow fetching from untrusted origins ([b09572a](vitejs/vite@b09572a))
-   fix: verify token for HMR WebSocket connection ([029dcd6](vitejs/vite@029dcd6))


## [v6.0.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small608-2025-01-20-small)

-   fix: avoid SSR HMR for HTML files ([#19193](vitejs/vite#19193)) ([3bd55bc](vitejs/vite@3bd55bc)), closes [#19193](vitejs/vite#19193)
-   fix: build time display 7m 60s ([#19108](vitejs/vite#19108)) ([cf0d2c8](vitejs/vite@cf0d2c8)), closes [#19108](vitejs/vite#19108)
-   fix: don't resolve URL starting with double slash ([#19059](vitejs/vite#19059)) ([35942cd](vitejs/vite@35942cd)), closes [#19059](vitejs/vite#19059)
-   fix: ensure `server.close()` only called once ([#19204](vitejs/vite#19204)) ([db81c2d](vitejs/vite@db81c2d)), closes [#19204](vitejs/vite#19204)
-   fix: resolve.conditions in ResolvedConfig was `defaultServerConditions` ([#19174](vitejs/vite#19174)) ([ad75c56](vitejs/vite@ad75c56)), closes [#19174](vitejs/vite#19174)
-   fix: tree shake stringified JSON imports ([#19189](vitejs/vite#19189)) ([f2aed62](vitejs/vite@f2aed62)), closes [#19189](vitejs/vite#19189)
-   fix: use shared sigterm callback ([#19203](vitejs/vite#19203)) ([47039f4](vitejs/vite@47039f4)), closes [#19203](vitejs/vite#19203)
-   fix(deps): update all non-major dependencies ([#19098](vitejs/vite#19098)) ([8639538](vitejs/vite@8639538)), closes [#19098](vitejs/vite#19098)
-   fix(optimizer): use correct default install state path for yarn PnP ([#19119](vitejs/vite#19119)) ([e690d8b](vitejs/vite@e690d8b)), closes [#19119](vitejs/vite#19119)
-   fix(types): improve `ESBuildOptions.include / exclude` type to allow `readonly (string | RegExp)[]`  ([ea53e70](vitejs/vite@ea53e70)), closes [#19146](vitejs/vite#19146)
-   chore(deps): update dependency pathe to v2 ([#19139](vitejs/vite#19139)) ([71506f0](vitejs/vite@71506f0)), closes [#19139](vitejs/vite#19139)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has workaround p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants