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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const os = require("os");
const path = require("path");
const url = require("url");
const util = require("util");
const fs = require("graceful-fs");
const ipaddr = require("ipaddr.js");
const defaultGateway = require("default-gateway");
Expand Down Expand Up @@ -2038,6 +2039,13 @@ class Server {
// bypassUrl from it otherwise bypassUrl would be null
// TODO remove in the next major in favor `context` and `router` options
const isByPassFuncDefined = typeof proxyConfig.bypass === "function";
if (isByPassFuncDefined) {
util.deprecate(
() => {},
"Using the 'bypass' option is deprecated. Please use the 'router' and 'context' options. Read more at https://github.com/chimurai/http-proxy-middleware/tree/v2.0.6#http-proxy-middleware-options",
"DEP_WEBPACK_DEV_SERVER_PROXY_BYPASS_ARGUMENT"
)();
}
const bypassUrl = isByPassFuncDefined
? await /** @type {ByPass} */ (proxyConfig.bypass)(
req,
Expand Down
13 changes: 13 additions & 0 deletions test/server/proxy-option.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const path = require("path");
const util = require("util");
const request = require("supertest");
const express = require("express");
const bodyParser = require("body-parser");
Expand Down Expand Up @@ -214,6 +215,18 @@ describe("proxy option", () => {
});

describe("bypass", () => {
it("should log deprecation warning when bypass is used", async () => {
const utilSpy = jest.spyOn(util, "deprecate");

expect(utilSpy.mock.calls[0][1]).toEqual(
"Using the 'bypass' option is deprecated. Please use the 'router' and 'context' options. Read more at https://github.com/chimurai/http-proxy-middleware/tree/v2.0.6#http-proxy-middleware-options"
);
expect(utilSpy.mock.calls[0][2]).toEqual(
"DEP_WEBPACK_DEV_SERVER_PROXY_BYPASS_ARGUMENT"
);

utilSpy.mockRestore();
});
it("can rewrite a request path", async () => {
const response = await req.get("/foo/bar.html");

Expand Down
Loading