From 1befecb3efa84436f859221628e00ff77b9bbd98 Mon Sep 17 00:00:00 2001 From: coderwei <916606569@qq.com> Date: Mon, 2 Sep 2024 18:44:09 +0800 Subject: [PATCH 1/4] fix: ensure req.url matches moduleByEtag URL to avoid incorrect 304 response --- packages/vite/src/node/server/middlewares/transform.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/server/middlewares/transform.ts b/packages/vite/src/node/server/middlewares/transform.ts index 12a440d4c10774..2bbe343bbcedaf 100644 --- a/packages/vite/src/node/server/middlewares/transform.ts +++ b/packages/vite/src/node/server/middlewares/transform.ts @@ -52,7 +52,11 @@ export function cachedTransformMiddleware( const ifNoneMatch = req.headers['if-none-match'] if (ifNoneMatch) { const moduleByEtag = server.moduleGraph.getModuleByEtag(ifNoneMatch) - if (moduleByEtag?.transformResult?.etag === ifNoneMatch) { + // #17987 + if ( + moduleByEtag?.transformResult?.etag === ifNoneMatch && + moduleByEtag?.url === req.url + ) { // For CSS requests, if the same CSS file is imported in a module, // the browser sends the request for the direct CSS request with the etag // from the imported CSS module. We ignore the etag in this case. From 62894d09f25af8ef6a0d0f968408dc8f2bc2a84c Mon Sep 17 00:00:00 2001 From: patak <583075+patak-dev@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:37:10 +0200 Subject: [PATCH 2/4] chore: update --- packages/vite/LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 8bebd20a00e112..888259317be6c7 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -2447,7 +2447,7 @@ Repository: alexeyraspopov/picocolors > ISC License > -> Copyright (c) 2021-2024 Oleksii Raspopov, Kostiantyn Denysov, Anton Verinov +> Copyright (c) 2021 Alexey Raspopov, Kostiantyn Denysov, Anton Verinov > > Permission to use, copy, modify, and/or distribute this software for any > purpose with or without fee is hereby granted, provided that the above From 4e2f6515289969794b4757a706c5038437438fed Mon Sep 17 00:00:00 2001 From: patak <583075+patak-dev@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:37:35 +0200 Subject: [PATCH 3/4] chore: update --- packages/vite/LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 888259317be6c7..9bd44e34f9f80f 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -2160,7 +2160,7 @@ Repository: vercel/ms > The MIT License (MIT) > -> Copyright (c) 2020 Vercel, Inc. +> Copyright (c) 2016 Zeit, Inc. > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal From 5c44a48f354094422182d656a93058143682482e Mon Sep 17 00:00:00 2001 From: patak <583075+patak-dev@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:37:58 +0200 Subject: [PATCH 4/4] chore: update --- packages/vite/LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 9bd44e34f9f80f..ddd5a6209512dc 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -2156,7 +2156,7 @@ Repository: lukeed/mrmime ## ms License: MIT -Repository: vercel/ms +Repository: zeit/ms > The MIT License (MIT) >