Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"hono": "^4.12.14",
"http-compression": "^1.1.3",
"http-proxy": "^1.18.1",
"http-proxy-middleware": "^3.0.5",
"http-proxy-middleware": "4.0.0-beta.3",
Comment thread
chenjiahan marked this conversation as resolved.
Comment thread
chenjiahan marked this conversation as resolved.
"ipaddr.js": "^2.3.0",
"launch-editor": "^2.13.2",
"nano-staged": "^0.9.0",
Expand Down
47 changes: 21 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 22 additions & 3 deletions tests/e2e/allowed-hosts.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const express = require('express');
const { rspack } = require('@rspack/core');
const { createProxyMiddleware } = require('http-proxy-middleware');
const {
createProxyMiddleware,
proxyEventsPlugin,
} = require('http-proxy-middleware');
const { RspackDevServer: Server } = require('@rspack/dev-server');
const config = require('../fixtures/client-config/rspack.config');
const runBrowser = require('../helpers/run-browser');
Expand Down Expand Up @@ -327,14 +330,30 @@ describe('allowed hosts', () => {

function startProxy(callback) {
const app = express();
const hostHeader = `[${devServerHost}]:${devServerPort}`;
const setProxyHost = (proxyReq) => {
proxyReq.setHeader('host', hostHeader);
};

app.use(
'/',
createProxyMiddleware({
target: `http://[${devServerHost}]:${devServerPort}`,
// http-proxy-middleware v4 fails on IPv6 string targets like
// "http://[::1]:port". Use a structured target, then restore the
// correct Host header for both HTTP and WS requests.
target: {
protocol: 'http:',
hostname: devServerHost,
port: devServerPort,
},
ws: true,
changeOrigin: true,
logger: console,
ejectPlugins: true,
plugins: [proxyEventsPlugin],
on: {
proxyReq: setProxyHost,
proxyReqWs: setProxyHost,
},
}),
);

Expand Down