http-proxy-middleware 3.0.0 → 3.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/errors.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export declare enum ERRORS {
2
2
  ERR_CONFIG_FACTORY_TARGET_MISSING = "[HPM] Missing \"target\" option. Example: {target: \"http://www.example.org\"}",
3
- ERR_CONTEXT_MATCHER_GENERIC = "[HPM] Invalid context. Expecting something like: \"/api\" or [\"/api\", \"/ajax\"]",
4
- ERR_CONTEXT_MATCHER_INVALID_ARRAY = "[HPM] Invalid pathFilter. Expecting something like: [\"/api\", \"/ajax\"] or [\"/api/**\", \"!**.html\"]",
3
+ ERR_CONTEXT_MATCHER_GENERIC = "[HPM] Invalid pathFilter. Expecting something like: \"/api\" or [\"/api\", \"/ajax\"]",
4
+ ERR_CONTEXT_MATCHER_INVALID_ARRAY = "[HPM] Invalid pathFilter. Plain paths (e.g. \"/api\") can not be mixed with globs (e.g. \"/api/**\"). Expecting something like: [\"/api\", \"/ajax\"] or [\"/api/**\", \"!**.html\"].",
5
5
  ERR_PATH_REWRITER_CONFIG = "[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function"
6
6
  }
package/dist/errors.js CHANGED
@@ -4,7 +4,7 @@ exports.ERRORS = void 0;
4
4
  var ERRORS;
5
5
  (function (ERRORS) {
6
6
  ERRORS["ERR_CONFIG_FACTORY_TARGET_MISSING"] = "[HPM] Missing \"target\" option. Example: {target: \"http://www.example.org\"}";
7
- ERRORS["ERR_CONTEXT_MATCHER_GENERIC"] = "[HPM] Invalid context. Expecting something like: \"/api\" or [\"/api\", \"/ajax\"]";
8
- ERRORS["ERR_CONTEXT_MATCHER_INVALID_ARRAY"] = "[HPM] Invalid pathFilter. Expecting something like: [\"/api\", \"/ajax\"] or [\"/api/**\", \"!**.html\"]";
7
+ ERRORS["ERR_CONTEXT_MATCHER_GENERIC"] = "[HPM] Invalid pathFilter. Expecting something like: \"/api\" or [\"/api\", \"/ajax\"]";
8
+ ERRORS["ERR_CONTEXT_MATCHER_INVALID_ARRAY"] = "[HPM] Invalid pathFilter. Plain paths (e.g. \"/api\") can not be mixed with globs (e.g. \"/api/**\"). Expecting something like: [\"/api\", \"/ajax\"] or [\"/api/**\", \"!**.html\"].";
9
9
  ERRORS["ERR_PATH_REWRITER_CONFIG"] = "[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function";
10
10
  })(ERRORS || (exports.ERRORS = ERRORS = {}));
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loggerPlugin = void 0;
4
+ const url_1 = require("url");
4
5
  const logger_1 = require("../../logger");
5
6
  const loggerPlugin = (proxyServer, options) => {
6
7
  const logger = (0, logger_1.getLogger)(options);
@@ -23,7 +24,11 @@ const loggerPlugin = (proxyServer, options) => {
23
24
  // BrowserSync uses req.originalUrl
24
25
  // Next.js doesn't have req.baseUrl
25
26
  const originalUrl = req.originalUrl ?? `${req.baseUrl || ''}${req.url}`;
26
- const exchange = `[HPM] ${req.method} ${originalUrl} -> ${proxyRes.req.protocol}//${proxyRes.req.host}${proxyRes.req.path} [${proxyRes.statusCode}]`;
27
+ // construct targetUrl
28
+ const target = new url_1.URL(options.target);
29
+ target.pathname = proxyRes.req.path;
30
+ const targetUrl = target.toString();
31
+ const exchange = `[HPM] ${req.method} ${originalUrl} -> ${targetUrl} [${proxyRes.statusCode}]`;
27
32
  logger.info(exchange);
28
33
  });
29
34
  /**
package/dist/types.d.ts CHANGED
@@ -11,7 +11,7 @@ import type * as httpProxy from 'http-proxy';
11
11
  import type * as net from 'net';
12
12
  export type NextFunction<T = (err?: any) => void> = T;
13
13
  export interface RequestHandler<TReq = http.IncomingMessage, TRes = http.ServerResponse, TNext = NextFunction> {
14
- (req: TReq, res: TRes, next?: TNext): void | Promise<void>;
14
+ (req: TReq, res: TRes, next?: TNext): Promise<void>;
15
15
  upgrade: (req: http.IncomingMessage, socket: net.Socket, head: Buffer) => void;
16
16
  }
17
17
  export type Filter<TReq = http.IncomingMessage> = string | string[] | ((pathname: string, req: TReq) => boolean);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "http-proxy-middleware",
3
- "version": "3.0.0",
3
+ "version": "3.0.1-beta.0",
4
4
  "description": "The one-liner node.js proxy middleware for connect, express, next.js and more",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,6 +22,9 @@
22
22
  "prepack": "yarn clean && yarn test && yarn build",
23
23
  "spellcheck": "npx --yes cspell --show-context --show-suggestions '**/*.*'"
24
24
  },
25
+ "publishConfig": {
26
+ "provenance": true
27
+ },
25
28
  "repository": {
26
29
  "type": "git",
27
30
  "url": "https://github.com/chimurai/http-proxy-middleware.git"
@@ -51,18 +54,18 @@
51
54
  },
52
55
  "homepage": "https://github.com/chimurai/http-proxy-middleware#readme",
53
56
  "devDependencies": {
54
- "@commitlint/cli": "17.7.1",
55
- "@commitlint/config-conventional": "17.7.0",
57
+ "@commitlint/cli": "19.2.1",
58
+ "@commitlint/config-conventional": "19.1.0",
56
59
  "@types/debug": "4.1.12",
57
60
  "@types/express": "4.17.21",
58
61
  "@types/is-glob": "4.0.4",
59
62
  "@types/jest": "29.5.12",
60
63
  "@types/micromatch": "4.0.6",
61
- "@types/node": "20.11.30",
62
- "@types/supertest": "2.0.12",
64
+ "@types/node": "20.12.5",
65
+ "@types/supertest": "6.0.2",
63
66
  "@types/ws": "8.5.10",
64
- "@typescript-eslint/eslint-plugin": "7.4.0",
65
- "@typescript-eslint/parser": "7.4.0",
67
+ "@typescript-eslint/eslint-plugin": "7.6.0",
68
+ "@typescript-eslint/parser": "7.6.0",
66
69
  "body-parser": "1.20.2",
67
70
  "browser-sync": "3.0.2",
68
71
  "connect": "3.7.0",
@@ -74,12 +77,12 @@
74
77
  "husky": "9.0.11",
75
78
  "jest": "29.7.0",
76
79
  "lint-staged": "15.2.2",
77
- "mockttp": "3.10.1",
80
+ "mockttp": "3.10.2",
78
81
  "open": "8.4.2",
79
82
  "prettier": "3.2.5",
80
83
  "supertest": "6.3.4",
81
84
  "ts-jest": "29.1.2",
82
- "typescript": "5.4.3",
85
+ "typescript": "5.4.4",
83
86
  "ws": "8.16.0"
84
87
  },
85
88
  "dependencies": {