diff --git a/.cspell.json b/.cspell.json index 75ccb46d8d..1976882978 100644 --- a/.cspell.json +++ b/.cspell.json @@ -2,6 +2,7 @@ "version": "0.2", "language": "en,en-gb", "words": [ + "apos", "camelcase", "tapable", "sockjs", @@ -69,7 +70,8 @@ "commitlint", "eslintcache", "hono", - "privkey" + "privkey", + "geomanist" ], "ignorePaths": [ "CHANGELOG.md", diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 24a35a06ad..8caf799d12 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -9,6 +9,6 @@ jobs: runs-on: ubuntu-latest steps: - name: "Checkout Repository" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Dependency Review" - uses: actions/dependency-review-action@v3 + uses: actions/dependency-review-action@v4 diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index bac3c2e10b..d6ef806925 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -69,7 +69,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - node-version: [18.x, 20.x, 22.x] + node-version: [18.x, 20.x, 22.x, 23.x] shard: ["1/4", "2/4", "3/4", "4/4"] webpack-version: [latest] @@ -120,6 +120,6 @@ jobs: if: matrix.node-version != '18.x' - name: Submit coverage data to codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index bf63204a15..1845e61878 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,32 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [5.2.1](https://github.com/webpack/webpack-dev-server/compare/v5.2.0...v6.0.0) (2025-03-26) + +### Security + +* cross-origin requests are not allowed unless allowed by `Access-Control-Allow-Origin` header +* requests with an IP addresses in the `Origin` header are not allowed to connect to WebSocket server unless configured by `allowedHosts` or it different from the `Host` header + +The above changes may make the dev server not work if you relied on such behavior, but unfortunately they carry security risks, so they were considered as fixes. + +### Bug Fixes + +* prevent overlay for errors caught by React error boundaries ([#5431](https://github.com/webpack/webpack-dev-server/issues/5431)) ([8c1abc9](https://github.com/webpack/webpack-dev-server/commit/8c1abc903ab444d9ce99e567b9a6c603e1ec06be)) +* take the first network found instead of the last one, this restores the same behavior as 5.0.4 ([#5411](https://github.com/webpack/webpack-dev-server/issues/5411)) ([ffd0b86](https://github.com/webpack/webpack-dev-server/commit/ffd0b86b790d372f90e17aea92cfd9def83fee96)) + +## [5.2.0](https://github.com/webpack/webpack-dev-server/compare/v5.1.0...v5.2.0) (2024-12-11) + + +### Features + +* added `getClientEntry` and `getClientHotEntry` methods to get clients entries ([dc642a8](https://github.com/webpack/webpack-dev-server/commit/dc642a832d45c23c5c7a08fbf29995e0db7e0d95)) + + +### Bug Fixes + +* speed up initial client bundling ([145b5d0](https://github.com/webpack/webpack-dev-server/commit/145b5d01610a16468fc32719a20366682b0e8572)) + ## [5.1.0](https://github.com/webpack/webpack-dev-server/compare/v5.0.4...v5.1.0) (2024-09-03) diff --git a/client-src/index.js b/client-src/index.js index d6614a7a67..522ae993db 100644 --- a/client-src/index.js +++ b/client-src/index.js @@ -1,14 +1,11 @@ /* global __resourceQuery, __webpack_hash__ */ /// import webpackHotLog from "webpack/hot/log.js"; -import stripAnsi from "./utils/stripAnsi.js"; -import parseURL from "./utils/parseURL.js"; +import hotEmitter from "webpack/hot/emitter.js"; import socket from "./socket.js"; import { formatProblem, createOverlay } from "./overlay.js"; -import { log, logEnabledFeatures, setLogLevel } from "./utils/log.js"; +import { log, setLogLevel } from "./utils/log.js"; import sendMessage from "./utils/sendMessage.js"; -import reloadApp from "./utils/reloadApp.js"; -import createSocketURL from "./utils/createSocketURL.js"; import { isProgressSupported, defineProgressElement } from "./progress.js"; /** @@ -48,13 +45,11 @@ const decodeOverlayOptions = (overlayOptions) => { ); // eslint-disable-next-line no-new-func - const overlayFilterFunction = new Function( + overlayOptions[property] = new Function( "message", `var callback = ${overlayFilterFunctionString} return callback(message)`, ); - - overlayOptions[property] = overlayFilterFunction; } }); } @@ -69,13 +64,75 @@ const status = { currentHash: __webpack_hash__, }; -/** @type {Options} */ -const options = { - hot: false, - liveReload: false, - progress: false, - overlay: false, +/** + * @returns {string} + */ +const getCurrentScriptSource = () => { + // `document.currentScript` is the most accurate way to find the current script, + // but is not supported in all browsers. + if (document.currentScript) { + return document.currentScript.getAttribute("src"); + } + + // Fallback to getting all scripts running in the document. + const scriptElements = document.scripts || []; + const scriptElementsWithSrc = Array.prototype.filter.call( + scriptElements, + (element) => element.getAttribute("src"), + ); + + if (scriptElementsWithSrc.length > 0) { + const currentScript = + scriptElementsWithSrc[scriptElementsWithSrc.length - 1]; + + return currentScript.getAttribute("src"); + } + + // Fail as there was no script to use. + throw new Error("[webpack-dev-server] Failed to get current script source."); }; + +/** + * @param {string} resourceQuery + * @returns {{ [key: string]: string | boolean }} + */ +const parseURL = (resourceQuery) => { + /** @type {{ [key: string]: string }} */ + let result = {}; + + if (typeof resourceQuery === "string" && resourceQuery !== "") { + const searchParams = resourceQuery.slice(1).split("&"); + + for (let i = 0; i < searchParams.length; i++) { + const pair = searchParams[i].split("="); + + result[pair[0]] = decodeURIComponent(pair[1]); + } + } else { + // Else, get the url from the + + + + `); + }); + htmlServer.listen(htmlServerPort, htmlServerHost); + + const { page, browser } = await runBrowser(); + try { + const pageErrors = []; + + page.on("pageerror", (error) => { + pageErrors.push(error); + }); + + const scriptTagRequest = page.waitForResponse( + `http://localhost:${devServerPort}/main.js`, + ); + + await page.goto(`http://${htmlServerHost}:${htmlServerPort}`); + + const response = await scriptTagRequest; + + expect(response.status()).toBe(403); + } catch (error) { + throw error; + } finally { + await browser.close(); + await server.stop(); + htmlServer.close(); + } + }); + + it("should return 200 for cross-origin cors non-module script tag requests", async () => { + const compiler = webpack(config); + const devServerOptions = { + port: devServerPort, + allowedHosts: "auto", + headers: { + "Access-Control-Allow-Origin": "*", + }, + }; + const server = new Server(devServerOptions, compiler); + + await server.start(); + + // Start a separate server for serving the HTML file + const http = require("http"); + const htmlServer = http.createServer((req, res) => { + res.writeHead(200, { "Content-Type": "text/html" }); + res.end(` + + + + + + + `); + }); + htmlServer.listen(htmlServerPort, htmlServerHost); + + const { page, browser } = await runBrowser(); + try { + const pageErrors = []; + + page.on("pageerror", (error) => { + pageErrors.push(error); + }); + + const scriptTagRequest = page.waitForResponse( + `http://localhost:${devServerPort}/main.js`, + ); + + await page.goto(`http://${htmlServerHost}:${htmlServerPort}`); + + const response = await scriptTagRequest; + + expect(response.status()).toBe(200); + } catch (error) { + throw error; + } finally { + await browser.close(); + await server.stop(); + htmlServer.close(); + } + }); +}); diff --git a/test/e2e/entry.test.js b/test/e2e/entry.test.js index 7505ec3eb2..ff07fbc01a 100644 --- a/test/e2e/entry.test.js +++ b/test/e2e/entry.test.js @@ -55,7 +55,7 @@ describe("entry", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -94,7 +94,7 @@ describe("entry", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -138,7 +138,7 @@ describe("entry", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -177,7 +177,7 @@ describe("entry", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -219,7 +219,7 @@ describe("entry", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -269,11 +269,11 @@ describe("entry", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/test.html`, { + await page.goto(`http://localhost:${port}/test.html`, { waitUntil: "networkidle0", }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/runtime.js` }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/foo.js` }); + await page.addScriptTag({ url: `http://localhost:${port}/runtime.js` }); + await page.addScriptTag({ url: `http://localhost:${port}/foo.js` }); await waitForConsoleLogFinished(consoleMessages); expect(consoleMessages).toMatchSnapshot("console messages"); @@ -320,11 +320,11 @@ describe("entry", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/test.html`, { + await page.goto(`http://localhost:${port}/test.html`, { waitUntil: "networkidle0", }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/runtime.js` }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/bar.js` }); + await page.addScriptTag({ url: `http://localhost:${port}/runtime.js` }); + await page.addScriptTag({ url: `http://localhost:${port}/bar.js` }); await waitForConsoleLogFinished(consoleMessages); expect(consoleMessages).toMatchSnapshot("console messages"); @@ -369,11 +369,11 @@ describe("entry", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/test.html`, { + await page.goto(`http://localhost:${port}/test.html`, { waitUntil: "networkidle0", }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/bar.js` }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/foo.js` }); + await page.addScriptTag({ url: `http://localhost:${port}/bar.js` }); + await page.addScriptTag({ url: `http://localhost:${port}/foo.js` }); await waitForConsoleLogFinished(consoleMessages); expect(consoleMessages).toMatchSnapshot("console messages"); @@ -417,7 +417,7 @@ describe("entry", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/headers.test.js b/test/e2e/headers.test.js index 2df4734496..d176cc7730 100644 --- a/test/e2e/headers.test.js +++ b/test/e2e/headers.test.js @@ -49,7 +49,7 @@ describe("headers option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -117,7 +117,7 @@ describe("headers option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -180,7 +180,7 @@ describe("headers option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -241,7 +241,7 @@ describe("headers option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -309,7 +309,7 @@ describe("headers option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -375,7 +375,7 @@ describe("headers option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -437,7 +437,7 @@ describe("headers option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/history-api-fallback.test.js b/test/e2e/history-api-fallback.test.js index f1fe2b6ba7..cf8874189d 100644 --- a/test/e2e/history-api-fallback.test.js +++ b/test/e2e/history-api-fallback.test.js @@ -51,7 +51,7 @@ describe("historyApiFallback option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { + const response = await page.goto(`http://localhost:${port}/foo`, { waitUntil: "networkidle0", }); @@ -114,7 +114,7 @@ describe("historyApiFallback option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { + const response = await page.goto(`http://localhost:${port}/foo`, { waitUntil: "networkidle0", }); @@ -181,7 +181,7 @@ describe("historyApiFallback option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { + const response = await page.goto(`http://localhost:${port}/foo`, { waitUntil: "networkidle0", }); @@ -210,7 +210,7 @@ describe("historyApiFallback option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}/random-file.txt`, + `http://localhost:${port}/random-file.txt`, { waitUntil: "networkidle2", }, @@ -276,7 +276,7 @@ describe("historyApiFallback option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/index.html`, { + const response = await page.goto(`http://localhost:${port}/index.html`, { waitUntil: "networkidle0", }); @@ -352,7 +352,7 @@ describe("historyApiFallback option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -380,7 +380,7 @@ describe("historyApiFallback option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/acme`, { + const response = await page.goto(`http://localhost:${port}/acme`, { waitUntil: "networkidle0", }); @@ -408,7 +408,7 @@ describe("historyApiFallback option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/other`, { + const response = await page.goto(`http://localhost:${port}/other`, { waitUntil: "networkidle0", }); @@ -476,7 +476,7 @@ describe("historyApiFallback option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { + const response = await page.goto(`http://localhost:${port}/foo`, { waitUntil: "networkidle0", }); @@ -552,7 +552,7 @@ describe("historyApiFallback option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { + const response = await page.goto(`http://localhost:${port}/foo`, { waitUntil: "networkidle0", }); @@ -625,7 +625,7 @@ describe("historyApiFallback option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { + const response = await page.goto(`http://localhost:${port}/foo`, { waitUntil: "networkidle0", }); @@ -645,7 +645,7 @@ describe("historyApiFallback option", () => { }); it("should perform HEAD request in same way as GET", async () => { - await page.goto(`http://127.0.0.1:${port}/foo`, { + await page.goto(`http://localhost:${port}/foo`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/host.test.js b/test/e2e/host.test.js index 4e6c108647..227e298b37 100644 --- a/test/e2e/host.test.js +++ b/test/e2e/host.test.js @@ -79,6 +79,16 @@ describe("host", () => { devServerOptions.host = host; } + if ( + host === "" || + typeof host === "undefined" || + host === "0.0.0.0" || + host === "::" || + host === "local-ipv6" + ) { + devServerOptions.allowedHosts = "all"; + } + const server = new Server(devServerOptions, compiler); let hostname = host; @@ -145,6 +155,16 @@ describe("host", () => { devServerOptions.host = host; } + if ( + host === "" || + typeof host === "undefined" || + host === "0.0.0.0" || + host === "::" || + host === "local-ipv6" + ) { + devServerOptions.allowedHosts = "all"; + } + const server = new Server(devServerOptions, compiler); let hostname = host; @@ -214,6 +234,16 @@ describe("host", () => { devServerOptions.host = host; } + if ( + host === "" || + typeof host === "undefined" || + host === "0.0.0.0" || + host === "::" || + host === "local-ipv6" + ) { + devServerOptions.allowedHosts = "all"; + } + const server = new Server(devServerOptions, compiler); let hostname = host; diff --git a/test/e2e/hot-and-live-reload.test.js b/test/e2e/hot-and-live-reload.test.js index e700eb7b65..c53694e60b 100644 --- a/test/e2e/hot-and-live-reload.test.js +++ b/test/e2e/hot-and-live-reload.test.js @@ -354,11 +354,11 @@ describe("hot and live reload", () => { if (webSocketTransport === "ws") { const ws = new WebSocket( - `ws://127.0.0.1:${devServerOptions.port}/ws`, + `ws://localhost:${devServerOptions.port}/ws`, { headers: { - host: `127.0.0.1:${devServerOptions.port}`, - origin: `http://127.0.0.1:${devServerOptions.port}`, + host: `localhost:${devServerOptions.port}`, + origin: `http://localhost:${devServerOptions.port}`, }, }, ); @@ -400,7 +400,7 @@ describe("hot and live reload", () => { }); } else { const sockjs = new SockJS( - `http://127.0.0.1:${devServerOptions.port}/ws`, + `http://localhost:${devServerOptions.port}/ws`, ); let opened = false; @@ -624,7 +624,7 @@ describe("simple hot config HMR plugin", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -691,7 +691,7 @@ describe("simple hot config HMR plugin with already added HMR plugin", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -822,7 +822,7 @@ describe("multi compiler hot config HMR plugin", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -885,7 +885,7 @@ describe("hot disabled HMR plugin", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/ipc.test.js b/test/e2e/ipc.test.js index debe2e1503..a29f7acf2e 100644 --- a/test/e2e/ipc.test.js +++ b/test/e2e/ipc.test.js @@ -19,7 +19,7 @@ describe("web socket server URL", () => { const websocketURLProtocol = webSocketServer === "ws" ? "ws" : "http"; it(`should work with the "ipc" option using "true" value ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; + const devServerHost = "localhost"; const proxyHost = devServerHost; const proxyPort = port1; @@ -123,7 +123,7 @@ describe("web socket server URL", () => { const pipeName = `webpack-dev-server.${process.pid}-1.sock`; const ipc = path.join(pipePrefix, pipeName); - const devServerHost = "127.0.0.1"; + const devServerHost = "localhost"; const proxyHost = devServerHost; const proxyPort = port1; @@ -241,7 +241,7 @@ describe("web socket server URL", () => { }); }); - const devServerHost = "127.0.0.1"; + const devServerHost = "localhost"; const proxyHost = devServerHost; const proxyPort = port1; diff --git a/test/e2e/lazy-compilation.test.js b/test/e2e/lazy-compilation.test.js index faa76eb3d1..e3c2db45f9 100644 --- a/test/e2e/lazy-compilation.test.js +++ b/test/e2e/lazy-compilation.test.js @@ -29,7 +29,7 @@ describe("lazy compilation", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/test.html`, { + await page.goto(`http://localhost:${port}/test.html`, { waitUntil: "domcontentloaded", }); await new Promise((resolve) => { @@ -72,7 +72,7 @@ describe("lazy compilation", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/test-one.html`, { + await page.goto(`http://localhost:${port}/test-one.html`, { waitUntil: "domcontentloaded", }); await new Promise((resolve) => { @@ -86,7 +86,7 @@ describe("lazy compilation", () => { }, 100); }); - await page.goto(`http://127.0.0.1:${port}/test-two.html`, { + await page.goto(`http://localhost:${port}/test-two.html`, { waitUntil: "domcontentloaded", }); await new Promise((resolve) => { diff --git a/test/e2e/mime-types.test.js b/test/e2e/mime-types.test.js index d55064ede2..ee71894d70 100644 --- a/test/e2e/mime-types.test.js +++ b/test/e2e/mime-types.test.js @@ -52,7 +52,7 @@ describe("mimeTypes option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { + const response = await page.goto(`http://localhost:${port}/main.js`, { waitUntil: "networkidle0", }); @@ -115,7 +115,7 @@ describe("mimeTypes option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/file.custom`, { + const response = await page.goto(`http://localhost:${port}/file.custom`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/module-federation.test.js b/test/e2e/module-federation.test.js index 2e471dab91..3bbf7a9e4a 100644 --- a/test/e2e/module-federation.test.js +++ b/test/e2e/module-federation.test.js @@ -45,7 +45,7 @@ describe("Module federation", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { + const response = await page.goto(`http://localhost:${port}/main.js`, { waitUntil: "networkidle0", }); @@ -103,7 +103,7 @@ describe("Module federation", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { + const response = await page.goto(`http://localhost:${port}/main.js`, { waitUntil: "networkidle0", }); @@ -135,7 +135,7 @@ describe("Module federation", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/foo.js`, { + const response = await page.goto(`http://localhost:${port}/foo.js`, { waitUntil: "networkidle0", }); @@ -193,7 +193,7 @@ describe("Module federation", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { + const response = await page.goto(`http://localhost:${port}/main.js`, { waitUntil: "networkidle0", }); @@ -252,7 +252,7 @@ describe("Module federation", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}/remoteEntry.js`, + `http://localhost:${port}/remoteEntry.js`, { waitUntil: "networkidle0", }, @@ -278,7 +278,7 @@ describe("Module federation", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { + const response = await page.goto(`http://localhost:${port}/main.js`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/multi-compiler.test.js b/test/e2e/multi-compiler.test.js index da60f8e053..6142094f93 100644 --- a/test/e2e/multi-compiler.test.js +++ b/test/e2e/multi-compiler.test.js @@ -34,7 +34,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -72,7 +72,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/one-main.html`, { + await page.goto(`http://localhost:${port}/one-main.html`, { waitUntil: "networkidle0", }); @@ -82,7 +82,7 @@ describe("multi compiler", () => { pageErrors = []; consoleMessages = []; - await page.goto(`http://127.0.0.1:${port}/two-main.html`, { + await page.goto(`http://localhost:${port}/two-main.html`, { waitUntil: "networkidle0", }); @@ -140,7 +140,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/one-main.html`, { + await page.goto(`http://localhost:${port}/one-main.html`, { waitUntil: "networkidle0", }); @@ -154,7 +154,7 @@ describe("multi compiler", () => { pageErrors = []; consoleMessages = []; - await page.goto(`http://127.0.0.1:${port}/two-main.html`, { + await page.goto(`http://localhost:${port}/two-main.html`, { waitUntil: "networkidle0", }); @@ -219,7 +219,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/one-main.html`, { + await page.goto(`http://localhost:${port}/one-main.html`, { waitUntil: "networkidle0", }); @@ -233,7 +233,7 @@ describe("multi compiler", () => { pageErrors = []; consoleMessages = []; - await page.goto(`http://127.0.0.1:${port}/two-main.html`, { + await page.goto(`http://localhost:${port}/two-main.html`, { waitUntil: "networkidle0", }); @@ -290,7 +290,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/one-main.html`, { + await page.goto(`http://localhost:${port}/one-main.html`, { waitUntil: "networkidle0", }); @@ -304,7 +304,7 @@ describe("multi compiler", () => { pageErrors = []; consoleMessages = []; - await page.goto(`http://127.0.0.1:${port}/two-main.html`, { + await page.goto(`http://localhost:${port}/two-main.html`, { waitUntil: "networkidle0", }); @@ -361,7 +361,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/one-main.html`, { + await page.goto(`http://localhost:${port}/one-main.html`, { waitUntil: "networkidle0", }); @@ -375,7 +375,7 @@ describe("multi compiler", () => { pageErrors = []; consoleMessages = []; - await page.goto(`http://127.0.0.1:${port}/two-main.html`, { + await page.goto(`http://localhost:${port}/two-main.html`, { waitUntil: "networkidle0", }); @@ -411,7 +411,7 @@ describe("multi compiler", () => { const consoleMessages = []; try { const serverResponse = await page.goto( - `http://127.0.0.1:${port}/server.js`, + `http://localhost:${port}/server.js`, { waitUntil: "networkidle0", }, @@ -430,7 +430,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/browser.html`, { + await page.goto(`http://localhost:${port}/browser.html`, { waitUntil: "networkidle0", }); } catch (error) { @@ -470,7 +470,7 @@ describe("multi compiler", () => { try { const serverResponse = await page.goto( - `http://127.0.0.1:${port}/server.js`, + `http://localhost:${port}/server.js`, { waitUntil: "networkidle0", }, @@ -500,7 +500,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/browser.html`, { + await page.goto(`http://localhost:${port}/browser.html`, { waitUntil: "networkidle0", }); @@ -545,7 +545,7 @@ describe("multi compiler", () => { try { const serverResponse = await page.goto( - `http://127.0.0.1:${port}/server.js`, + `http://localhost:${port}/server.js`, { waitUntil: "networkidle0", }, @@ -575,7 +575,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/browser.html`, { + await page.goto(`http://localhost:${port}/browser.html`, { waitUntil: "networkidle0", }); @@ -624,7 +624,7 @@ describe("multi compiler", () => { try { const serverResponse = await page.goto( - `http://127.0.0.1:${port}/server.js`, + `http://localhost:${port}/server.js`, { waitUntil: "networkidle0", }, @@ -646,7 +646,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/browser.html`, { + await page.goto(`http://localhost:${port}/browser.html`, { waitUntil: "networkidle0", }); @@ -663,7 +663,7 @@ describe("multi compiler", () => { pageErrors = []; consoleMessages = []; - await page.goto(`http://127.0.0.1:${port}/browser.html`, { + await page.goto(`http://localhost:${port}/browser.html`, { waitUntil: "networkidle0", }); @@ -713,7 +713,7 @@ describe("multi compiler", () => { try { const serverResponse = await page.goto( - `http://127.0.0.1:${port}/server.js`, + `http://localhost:${port}/server.js`, { waitUntil: "networkidle0", }, @@ -735,7 +735,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/browser.html`, { + await page.goto(`http://localhost:${port}/browser.html`, { waitUntil: "networkidle0", }); @@ -752,7 +752,7 @@ describe("multi compiler", () => { pageErrors = []; consoleMessages = []; - await page.goto(`http://127.0.0.1:${port}/browser.html`, { + await page.goto(`http://localhost:${port}/browser.html`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/on-listening.test.js b/test/e2e/on-listening.test.js index 4a88d908e7..1e2be08a9d 100644 --- a/test/e2e/on-listening.test.js +++ b/test/e2e/on-listening.test.js @@ -68,7 +68,7 @@ describe("onListening option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}/listening/some/path`, + `http://localhost:${port}/listening/some/path`, { waitUntil: "networkidle0", }, @@ -108,7 +108,7 @@ describe("onListening option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}/listening/some/path`, + `http://localhost:${port}/listening/some/path`, { waitUntil: "networkidle0", }, diff --git a/test/e2e/options-middleware.test.js b/test/e2e/options-middleware.test.js index 613c39f735..9f8f2cef2f 100644 --- a/test/e2e/options-middleware.test.js +++ b/test/e2e/options-middleware.test.js @@ -65,7 +65,7 @@ describe("handle options-request correctly", () => { await server.start(); const { page, browser } = await runBrowser(); - const prefixUrl = "http://127.0.0.1"; + const prefixUrl = "http://localhost"; const htmlUrl = `${prefixUrl}:${portForServer}/test.html`; const appUrl = `${prefixUrl}:${portForApp}`; diff --git a/test/e2e/port.test.js b/test/e2e/port.test.js index 695196a956..9939a870aa 100644 --- a/test/e2e/port.test.js +++ b/test/e2e/port.test.js @@ -89,7 +89,7 @@ describe("port", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${address.port}/`, { + await page.goto(`http://localhost:${address.port}/`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/server.test.js b/test/e2e/server.test.js index 29b94e4546..4324b5dbc0 100644 --- a/test/e2e/server.test.js +++ b/test/e2e/server.test.js @@ -71,7 +71,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -131,7 +131,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -191,7 +191,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -251,7 +251,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -342,7 +342,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -433,7 +433,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -522,7 +522,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -620,7 +620,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -695,7 +695,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -770,7 +770,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -852,7 +852,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -930,7 +930,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -1021,7 +1021,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -1117,7 +1117,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -1201,7 +1201,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -1341,7 +1341,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { + const response = await page.goto(`https://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -1417,7 +1417,7 @@ describe("server option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/setup-exit-signals.test.js b/test/e2e/setup-exit-signals.test.js index 7a88ffa02a..0de9236d34 100644 --- a/test/e2e/setup-exit-signals.test.js +++ b/test/e2e/setup-exit-signals.test.js @@ -76,7 +76,7 @@ describe("setupExitSignals option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/setup-middlewares.test.js b/test/e2e/setup-middlewares.test.js index 5187aaa8a7..e33b2256bd 100644 --- a/test/e2e/setup-middlewares.test.js +++ b/test/e2e/setup-middlewares.test.js @@ -92,7 +92,7 @@ describe("setupMiddlewares option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}/setup-middleware/some/path`, + `http://localhost:${port}/setup-middleware/some/path`, { waitUntil: "networkidle0", }, @@ -104,7 +104,7 @@ describe("setupMiddlewares option", () => { expect(response.status()).toMatchSnapshot("response status"); expect(await response.text()).toMatchSnapshot("response text"); - const response1 = await page.goto(`http://127.0.0.1:${port}/foo/bar`, { + const response1 = await page.goto(`http://localhost:${port}/foo/bar`, { waitUntil: "networkidle0", }); @@ -114,7 +114,7 @@ describe("setupMiddlewares option", () => { expect(response1.status()).toMatchSnapshot("response status"); expect(await response1.text()).toMatchSnapshot("response text"); - const response2 = await page.goto(`http://127.0.0.1:${port}/foo/bar/baz`, { + const response2 = await page.goto(`http://localhost:${port}/foo/bar/baz`, { waitUntil: "networkidle0", }); @@ -125,7 +125,7 @@ describe("setupMiddlewares option", () => { expect(await response2.text()).toMatchSnapshot("response text"); const response3 = await page.goto( - `http://127.0.0.1:${port}/setup-middleware/unknown`, + `http://localhost:${port}/setup-middleware/unknown`, { waitUntil: "networkidle0", }, @@ -160,7 +160,7 @@ describe("setupMiddlewares option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}/setup-middleware/some/path`, + `http://localhost:${port}/setup-middleware/some/path`, { waitUntil: "networkidle0", }, diff --git a/test/e2e/static-directory.test.js b/test/e2e/static-directory.test.js index bf9e69b1e9..982aca59a3 100644 --- a/test/e2e/static-directory.test.js +++ b/test/e2e/static-directory.test.js @@ -61,7 +61,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -85,7 +85,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/other.html`, { + const response = await page.goto(`http://localhost:${port}/other.html`, { waitUntil: "networkidle0", }); @@ -178,7 +178,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/assets`, { + const response = await page.goto(`http://localhost:${port}/assets`, { waitUntil: "networkidle0", }); @@ -202,7 +202,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/bar`, { + const response = await page.goto(`http://localhost:${port}/bar`, { waitUntil: "networkidle0", }); @@ -263,7 +263,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/assets/`, { + const response = await page.goto(`http://localhost:${port}/assets/`, { waitUntil: "networkidle0", }); @@ -290,7 +290,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/bar/`, { + const response = await page.goto(`http://localhost:${port}/bar/`, { waitUntil: "networkidle0", }); @@ -350,7 +350,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/assets`, { + const response = await page.goto(`http://localhost:${port}/assets`, { waitUntil: "networkidle0", }); @@ -377,7 +377,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/bar`, { + const response = await page.goto(`http://localhost:${port}/bar`, { waitUntil: "networkidle0", }); @@ -434,7 +434,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -458,7 +458,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/foo.html`, { + const response = await page.goto(`http://localhost:${port}/foo.html`, { waitUntil: "networkidle0", }); @@ -607,7 +607,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/index.html`, { + const response = await page.goto(`http://localhost:${port}/index.html`, { waitUntil: "networkidle0", }); @@ -668,7 +668,7 @@ describe("static.directory option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/index.html`, { + const response = await page.goto(`http://localhost:${port}/index.html`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/static-public-path.test.js b/test/e2e/static-public-path.test.js index 4a38eb2385..6818345f73 100644 --- a/test/e2e/static-public-path.test.js +++ b/test/e2e/static-public-path.test.js @@ -60,7 +60,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, + `http://localhost:${port}${staticPublicPath}/`, { waitUntil: "networkidle0", }, @@ -87,7 +87,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/other.html`, + `http://localhost:${port}${staticPublicPath}/other.html`, { waitUntil: "networkidle0", }, @@ -152,7 +152,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/assets`, + `http://localhost:${port}${staticPublicPath}/assets`, { waitUntil: "networkidle0", }, @@ -179,7 +179,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/bar`, + `http://localhost:${port}${staticPublicPath}/bar`, { waitUntil: "networkidle0", }, @@ -244,7 +244,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/assets`, + `http://localhost:${port}${staticPublicPath}/assets`, { waitUntil: "networkidle0", }, @@ -271,7 +271,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/bar`, + `http://localhost:${port}${staticPublicPath}/bar`, { waitUntil: "networkidle0", }, @@ -336,7 +336,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/assets`, + `http://localhost:${port}${staticPublicPath}/assets`, { waitUntil: "networkidle0", }, @@ -363,7 +363,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/bar`, + `http://localhost:${port}${staticPublicPath}/bar`, { waitUntil: "networkidle0", }, @@ -432,7 +432,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, + `http://localhost:${port}${staticPublicPath}/`, { waitUntil: "networkidle0", }, @@ -459,7 +459,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/foo.html`, + `http://localhost:${port}${staticPublicPath}/foo.html`, { waitUntil: "networkidle0", }, @@ -528,7 +528,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/index.html`, + `http://localhost:${port}${staticPublicPath}/index.html`, { waitUntil: "networkidle0", }, @@ -591,7 +591,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/assets/example.txt`, + `http://localhost:${port}${staticPublicPath}/assets/example.txt`, { waitUntil: "networkidle0", }, @@ -656,7 +656,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, + `http://localhost:${port}${staticPublicPath}/`, { waitUntil: "networkidle0", }, @@ -686,7 +686,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, + `http://localhost:${port}${staticPublicPath}/`, { waitUntil: "networkidle0", }, @@ -716,7 +716,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, + `http://localhost:${port}${staticPublicPath}/`, { waitUntil: "networkidle0", }, @@ -746,7 +746,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, + `http://localhost:${port}${staticPublicPath}/`, { waitUntil: "networkidle0", }, @@ -776,7 +776,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, + `http://localhost:${port}${staticPublicPath}/`, { waitUntil: "networkidle0", }, @@ -806,7 +806,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, + `http://localhost:${port}${staticPublicPath}/`, { waitUntil: "networkidle0", }, @@ -875,7 +875,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, + `http://localhost:${port}${staticPublicPath}/`, { waitUntil: "networkidle0", }, @@ -902,7 +902,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/other.html`, + `http://localhost:${port}${staticPublicPath}/other.html`, { waitUntil: "networkidle0", }, @@ -929,7 +929,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${otherStaticPublicPath}/foo.html`, + `http://localhost:${port}${otherStaticPublicPath}/foo.html`, { waitUntil: "networkidle0", }, @@ -1000,7 +1000,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, + `http://localhost:${port}${staticPublicPath}/`, { waitUntil: "networkidle0", }, @@ -1027,7 +1027,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/other.html`, + `http://localhost:${port}${staticPublicPath}/other.html`, { waitUntil: "networkidle0", }, @@ -1054,7 +1054,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/foo.html`, + `http://localhost:${port}${staticPublicPath}/foo.html`, { waitUntil: "networkidle0", }, @@ -1081,7 +1081,7 @@ describe("static.publicPath option", () => { }); const response = await page.goto( - `http://127.0.0.1:${port}${otherStaticPublicPath}/foo.html`, + `http://localhost:${port}${otherStaticPublicPath}/foo.html`, { waitUntil: "networkidle0", }, diff --git a/test/e2e/target.test.js b/test/e2e/target.test.js index 5e3d29c8c4..940966fee7 100644 --- a/test/e2e/target.test.js +++ b/test/e2e/target.test.js @@ -58,7 +58,7 @@ describe("target", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -113,7 +113,7 @@ describe("target", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -164,7 +164,7 @@ describe("target", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/watch-files.test.js b/test/e2e/watch-files.test.js index 6c70b2d8fa..732e1077e3 100644 --- a/test/e2e/watch-files.test.js +++ b/test/e2e/watch-files.test.js @@ -58,7 +58,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -129,7 +129,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -200,7 +200,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -276,7 +276,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -352,7 +352,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -425,7 +425,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -506,7 +506,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -647,7 +647,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/`, { + const response = await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); diff --git a/test/e2e/web-socket-communication.test.js b/test/e2e/web-socket-communication.test.js index f5ca99b5df..21731cf88b 100644 --- a/test/e2e/web-socket-communication.test.js +++ b/test/e2e/web-socket-communication.test.js @@ -40,7 +40,7 @@ describe("web socket communication", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -92,7 +92,7 @@ describe("web socket communication", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); await browser.close(); @@ -142,7 +142,7 @@ describe("web socket communication", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); @@ -181,10 +181,10 @@ describe("web socket communication", () => { server.webSocketServer.heartbeatInterval = 100; await new Promise((resolve, reject) => { - const ws = new WebSocket(`ws://127.0.0.1:${devServerOptions.port}/ws`, { + const ws = new WebSocket(`ws://localhost:${devServerOptions.port}/ws`, { headers: { - host: `127.0.0.1:${devServerOptions.port}`, - origin: `http://127.0.0.1:${devServerOptions.port}`, + host: `localhost:${devServerOptions.port}`, + origin: `http://localhost:${devServerOptions.port}`, }, }); diff --git a/test/e2e/web-socket-server-url.test.js b/test/e2e/web-socket-server-url.test.js index f0f33ea33b..a193262fec 100644 --- a/test/e2e/web-socket-server-url.test.js +++ b/test/e2e/web-socket-server-url.test.js @@ -211,7 +211,7 @@ describe("web socket server URL", () => { }); it(`should work behind proxy, when hostnames are different and ports are different ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; + const devServerHost = "localhost"; const devServerPort = port1; const proxyHost = Server.internalIPSync("v4"); const proxyPort = port2; @@ -2267,7 +2267,7 @@ describe("web socket server URL", () => { }); it(`should work with "server: 'https'" option ("${webSocketServer}")`, async () => { - const hostname = "127.0.0.1"; + const hostname = "localhost"; const compiler = webpack(config); const devServerOptions = { webSocketServer, @@ -2345,7 +2345,7 @@ describe("web socket server URL", () => { }); it(`should work with "server: 'spdy'" option ("${webSocketServer}")`, async () => { - const hostname = "127.0.0.1"; + const hostname = "localhost"; const compiler = webpack(config); const devServerOptions = { webSocketServer, @@ -2430,6 +2430,7 @@ describe("web socket server URL", () => { webSocketServer, port: "auto", host: "0.0.0.0", + allowedHosts: "all", }; const server = new Server(devServerOptions, compiler); diff --git a/test/e2e/web-socket-server.test.js b/test/e2e/web-socket-server.test.js index fa5848c7c3..b3ffde1fb1 100644 --- a/test/e2e/web-socket-server.test.js +++ b/test/e2e/web-socket-server.test.js @@ -49,7 +49,7 @@ describe("web socket server", () => { sessionSubscribe(session); - await page.goto(`http://127.0.0.1:${port}/`, { + await page.goto(`http://localhost:${port}/`, { waitUntil: "networkidle0", }); diff --git a/test/fixtures/custom-client/CustomClientEntry.js b/test/fixtures/custom-client/CustomClientEntry.js new file mode 100644 index 0000000000..ee237e53f6 --- /dev/null +++ b/test/fixtures/custom-client/CustomClientEntry.js @@ -0,0 +1,3 @@ +"use strict"; + +console.log("custom client entry"); diff --git a/test/fixtures/custom-client/CustomClientHotEntry.js b/test/fixtures/custom-client/CustomClientHotEntry.js new file mode 100644 index 0000000000..6a574ef5c5 --- /dev/null +++ b/test/fixtures/custom-client/CustomClientHotEntry.js @@ -0,0 +1,3 @@ +"use strict"; + +console.log("custom client hot entry"); diff --git a/test/ports-map.js b/test/ports-map.js index 00eb84a7dd..b3a3bc313a 100644 --- a/test/ports-map.js +++ b/test/ports-map.js @@ -81,6 +81,7 @@ const listOfTests = { "setup-middlewares-option": 1, "options-request-response": 2, app: 1, + "cross-origin-request": 2, }; let startPort = 8089; diff --git a/types/lib/Server.d.ts b/types/lib/Server.d.ts index 19e8e342fb..a8e54e2df8 100644 --- a/types/lib/Server.d.ts +++ b/types/lib/Server.d.ts @@ -1134,7 +1134,7 @@ declare class Server< */ static findIp( gatewayOrFamily: string, - isInternal?: boolean | undefined, + isInternal?: boolean, ): string | undefined; /** * @param {"v4" | "v6"} family @@ -1230,6 +1230,14 @@ declare class Server< * @returns {T} */ private getServerTransport; + /** + * @returns {string} + */ + getClientEntry(): string; + /** + * @returns {string | void} + */ + getClientHotEntry(): string | void; /** * @private * @returns {void} @@ -1339,13 +1347,25 @@ declare class Server< * @param {NextFunction} next */ private setHeaders; + /** + * @private + * @param {string} value + * @returns {boolean} + */ + private isHostAllowed; /** * @private * @param {{ [key: string]: string | undefined }} headers * @param {string} headerToCheck * @returns {boolean} */ - private checkHeader; + private isValidHost; + /** + * @private + * @param {{ [key: string]: string | undefined }} headers + * @returns {boolean} + */ + private isSameOrigin; /** * @param {ClientConnection[]} clients * @param {string} type @@ -1369,16 +1389,11 @@ declare class Server< * @param {string | string[]} watchPath * @param {WatchOptions} [watchOptions] */ - watchFiles( - watchPath: string | string[], - watchOptions?: import("chokidar").WatchOptions | undefined, - ): void; + watchFiles(watchPath: string | string[], watchOptions?: WatchOptions): void; /** * @param {import("webpack-dev-middleware").Callback} [callback] */ - invalidate( - callback?: import("webpack-dev-middleware").Callback | undefined, - ): void; + invalidate(callback?: import("webpack-dev-middleware").Callback): void; /** * @returns {Promise} */ @@ -1386,7 +1401,7 @@ declare class Server< /** * @param {(err?: Error) => void} [callback] */ - startCallback(callback?: ((err?: Error) => void) | undefined): void; + startCallback(callback?: (err?: Error) => void): void; /** * @returns {Promise} */ @@ -1394,7 +1409,7 @@ declare class Server< /** * @param {(err?: Error) => void} [callback] */ - stopCallback(callback?: ((err?: Error) => void) | undefined): void; + stopCallback(callback?: (err?: Error) => void): void; } declare namespace Server { export {