Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vitejs/vite
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.5.7
Choose a base ref
...
head repository: vitejs/vite
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 947f0c197e3c9111da3a87ef7096ba0b5c5a9389
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Jan 20, 2025

  1. fix: try parse server.origin URL (#19241)

    bluwy authored and patak-dev committed Jan 20, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    dgollahon Daniel Gollahon
    Copy the full SHA
    3680bad View commit details
  2. release: v4.5.8

    patak-dev committed Jan 20, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    dgollahon Daniel Gollahon
    Copy the full SHA
    947f0c1 View commit details
Showing with 13 additions and 3 deletions.
  1. +6 −0 packages/vite/CHANGELOG.md
  2. +1 −1 packages/vite/package.json
  3. +6 −2 packages/vite/src/node/server/middlewares/hostCheck.ts
6 changes: 6 additions & 0 deletions packages/vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## <small>4.5.8 (2025-01-20)</small>

* fix: try parse `server.origin` URL (#19241) ([3680bad](https://github.com/vitejs/vite/commit/3680bad)), closes [#19241](https://github.com/vitejs/vite/issues/19241)



## <small>4.5.7 (2025-01-20)</small>

* fix: `crypto.getRandomValues` is not available in old Node versions (#19237) ([f4d3c46](https://github.com/vitejs/vite/commit/f4d3c46)), closes [#19237](https://github.com/vitejs/vite/issues/19237)
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite",
"version": "4.5.7",
"version": "4.5.8",
"type": "module",
"license": "MIT",
"author": "Evan You",
8 changes: 6 additions & 2 deletions packages/vite/src/node/server/middlewares/hostCheck.ts
Original file line number Diff line number Diff line change
@@ -37,8 +37,12 @@ export function getAdditionalAllowedHosts(
// allow server origin by default as that indicates that the user is
// expecting Vite to respond on that host
if (resolvedServerOptions.origin) {
const serverOriginUrl = new URL(resolvedServerOptions.origin)
list.push(serverOriginUrl.hostname)
// some frameworks may pass the origin as a placeholder, so it's not
// possible to parse as URL, so use a try-catch here as a best effort
try {
const serverOriginUrl = new URL(resolvedServerOptions.origin)
list.push(serverOriginUrl.hostname)
} catch {}
}

return list