Skip to content

Commit 9b5b8d7

Browse files
LiviaMedeirosdanielleadams
authored andcommitted
esm: throw on any non-2xx response
Treat redirects without Location and other 3xx responses as errors PR-URL: #43742 Refs: #43689 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
1 parent f28198c commit 9b5b8d7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/internal/modules/esm/fetch_module.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ function fetchWithRedirects(parsed) {
148148
err.message = `Cannot find module '${parsed.href}', HTTP 404`;
149149
throw err;
150150
}
151-
if (res.statusCode < 200 || res.statusCode >= 400) {
151+
// This condition catches all unsupported status codes, including
152+
// 3xx redirection codes without `Location` HTTP header.
153+
if (res.statusCode < 200 || res.statusCode >= 300) {
152154
throw new ERR_NETWORK_IMPORT_DISALLOWED(
153155
res.headers.location,
154156
parsed.href,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy