@sitecore-jss/sitecore-jss-proxy 21.1.0-canary.99 → 21.1.1

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/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  This module is provided as a part of Sitecore JavaScript Rendering SDK (JSS). It contains the headless-mode SSR proxy implementation.
4
4
 
5
- <!---
6
- @TODO: Update to version 20.0.0 docs before release
7
- -->
8
- [Documentation](https://doc.sitecore.com/xp/en/developers/hd/190/sitecore-headless-development/server-side-render-jss-apps-headlessly-using-the-jss-proxy.html)
9
5
 
10
- [API reference documentation](/ref-docs/sitecore-jss-proxy/).
6
+ [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/210/sitecore-headless-development/server-side-render-jss-apps-headlessly-using-the-jss-proxy.html)
7
+
8
+ [API reference documentation](/ref-docs/sitecore-jss-proxy/)
package/dist/cjs/index.js CHANGED
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.rewriteRequestPath = exports.removeEmptyAnalyticsCookie = void 0;
16
- const http_proxy_middleware_1 = __importDefault(require("http-proxy-middleware"));
16
+ const http_proxy_middleware_1 = require("http-proxy-middleware");
17
17
  const http_status_codes_1 = __importDefault(require("http-status-codes"));
18
18
  const set_cookie_parser_1 = __importDefault(require("set-cookie-parser"));
19
19
  const zlib_1 = __importDefault(require("zlib")); // node.js standard lib
@@ -237,8 +237,8 @@ function renderAppToResponse(proxyResponse, request, serverResponse, renderer, c
237
237
  }
238
238
  /**
239
239
  * @param {IncomingMessage} proxyResponse
240
- * @param {IncomingMessage} request
241
- * @param {ServerResponse} serverResponse
240
+ * @param {Request} request
241
+ * @param {Response} serverResponse
242
242
  * @param {AppRenderer} renderer
243
243
  * @param {ProxyConfig} config
244
244
  */
@@ -263,7 +263,7 @@ function handleProxyResponse(proxyResponse, request, serverResponse, renderer, c
263
263
  }
264
264
  /**
265
265
  * @param {string} reqPath
266
- * @param {IncomingMessage} req
266
+ * @param {Request} req
267
267
  * @param {ProxyConfig} config
268
268
  * @param {RouteUrlParser} parseRouteUrl
269
269
  */
@@ -371,12 +371,13 @@ function isUrlIgnored(originalUrl, config, noDebug = false) {
371
371
  }
372
372
  /**
373
373
  * @param {ClientRequest} proxyReq
374
- * @param {IncomingMessage} req
375
- * @param {ServerResponse} res
374
+ * @param {Request} req
375
+ * @param {Response} res
376
+ * @param {ServerOptions} options
376
377
  * @param {ProxyConfig} config
377
378
  * @param {Function} customOnProxyReq
378
379
  */
379
- function handleProxyRequest(proxyReq, req, res, config, customOnProxyReq) {
380
+ function handleProxyRequest(proxyReq, req, res, options, config, customOnProxyReq) {
380
381
  // if a HEAD request, we still need to issue a GET so we can return accurate headers
381
382
  if (proxyReq.method === 'HEAD' &&
382
383
  !isUrlIgnored(req.originalUrl, config, true)) {
@@ -387,7 +388,7 @@ function handleProxyRequest(proxyReq, req, res, config, customOnProxyReq) {
387
388
  }
388
389
  // invoke custom onProxyReq
389
390
  if (customOnProxyReq) {
390
- customOnProxyReq(proxyReq, req, res);
391
+ customOnProxyReq(proxyReq, req, res, options);
391
392
  }
392
393
  }
393
394
  /**
@@ -408,7 +409,7 @@ function createOptions(renderer, config, parseRouteUrl) {
408
409
  console.log('DEBUG: Final proxy config', config);
409
410
  }
410
411
  const customOnProxyReq = (_a = config.proxyOptions) === null || _a === void 0 ? void 0 : _a.onProxyReq;
411
- return Object.assign(Object.assign({}, config.proxyOptions), { target: config.apiHost, changeOrigin: true, ws: config.ws || false, pathRewrite: (reqPath, req) => rewriteRequestPath(reqPath, req, config, parseRouteUrl), logLevel: config.debug ? 'debug' : 'info', onProxyReq: (proxyReq, req, res) => handleProxyRequest(proxyReq, req, res, config, customOnProxyReq), onProxyRes: (proxyRes, req, res) => handleProxyResponse(proxyRes, req, res, renderer, config) });
412
+ return Object.assign(Object.assign({}, config.proxyOptions), { target: config.apiHost, changeOrigin: true, ws: config.ws || false, pathRewrite: (reqPath, req) => rewriteRequestPath(reqPath, req, config, parseRouteUrl), logLevel: config.debug ? 'debug' : 'info', onProxyReq: (proxyReq, req, res, options) => handleProxyRequest(proxyReq, req, res, options, config, customOnProxyReq), onProxyRes: (proxyRes, req, res) => handleProxyResponse(proxyRes, req, res, renderer, config) });
412
413
  }
413
414
  /**
414
415
  * @param {AppRenderer} renderer
@@ -417,6 +418,6 @@ function createOptions(renderer, config, parseRouteUrl) {
417
418
  */
418
419
  function scProxy(renderer, config, parseRouteUrl) {
419
420
  const options = createOptions(renderer, config, parseRouteUrl);
420
- return (0, http_proxy_middleware_1.default)(options);
421
+ return (0, http_proxy_middleware_1.createProxyMiddleware)(options);
421
422
  }
422
423
  exports.default = scProxy;
package/dist/esm/index.js CHANGED
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import proxy from 'http-proxy-middleware';
10
+ import { createProxyMiddleware } from 'http-proxy-middleware';
11
11
  import HttpStatus from 'http-status-codes';
12
12
  import setCookieParser from 'set-cookie-parser';
13
13
  import zlib from 'zlib'; // node.js standard lib
@@ -230,8 +230,8 @@ function renderAppToResponse(proxyResponse, request, serverResponse, renderer, c
230
230
  }
231
231
  /**
232
232
  * @param {IncomingMessage} proxyResponse
233
- * @param {IncomingMessage} request
234
- * @param {ServerResponse} serverResponse
233
+ * @param {Request} request
234
+ * @param {Response} serverResponse
235
235
  * @param {AppRenderer} renderer
236
236
  * @param {ProxyConfig} config
237
237
  */
@@ -256,7 +256,7 @@ function handleProxyResponse(proxyResponse, request, serverResponse, renderer, c
256
256
  }
257
257
  /**
258
258
  * @param {string} reqPath
259
- * @param {IncomingMessage} req
259
+ * @param {Request} req
260
260
  * @param {ProxyConfig} config
261
261
  * @param {RouteUrlParser} parseRouteUrl
262
262
  */
@@ -363,12 +363,13 @@ function isUrlIgnored(originalUrl, config, noDebug = false) {
363
363
  }
364
364
  /**
365
365
  * @param {ClientRequest} proxyReq
366
- * @param {IncomingMessage} req
367
- * @param {ServerResponse} res
366
+ * @param {Request} req
367
+ * @param {Response} res
368
+ * @param {ServerOptions} options
368
369
  * @param {ProxyConfig} config
369
370
  * @param {Function} customOnProxyReq
370
371
  */
371
- function handleProxyRequest(proxyReq, req, res, config, customOnProxyReq) {
372
+ function handleProxyRequest(proxyReq, req, res, options, config, customOnProxyReq) {
372
373
  // if a HEAD request, we still need to issue a GET so we can return accurate headers
373
374
  if (proxyReq.method === 'HEAD' &&
374
375
  !isUrlIgnored(req.originalUrl, config, true)) {
@@ -379,7 +380,7 @@ function handleProxyRequest(proxyReq, req, res, config, customOnProxyReq) {
379
380
  }
380
381
  // invoke custom onProxyReq
381
382
  if (customOnProxyReq) {
382
- customOnProxyReq(proxyReq, req, res);
383
+ customOnProxyReq(proxyReq, req, res, options);
383
384
  }
384
385
  }
385
386
  /**
@@ -400,7 +401,7 @@ function createOptions(renderer, config, parseRouteUrl) {
400
401
  console.log('DEBUG: Final proxy config', config);
401
402
  }
402
403
  const customOnProxyReq = (_a = config.proxyOptions) === null || _a === void 0 ? void 0 : _a.onProxyReq;
403
- return Object.assign(Object.assign({}, config.proxyOptions), { target: config.apiHost, changeOrigin: true, ws: config.ws || false, pathRewrite: (reqPath, req) => rewriteRequestPath(reqPath, req, config, parseRouteUrl), logLevel: config.debug ? 'debug' : 'info', onProxyReq: (proxyReq, req, res) => handleProxyRequest(proxyReq, req, res, config, customOnProxyReq), onProxyRes: (proxyRes, req, res) => handleProxyResponse(proxyRes, req, res, renderer, config) });
404
+ return Object.assign(Object.assign({}, config.proxyOptions), { target: config.apiHost, changeOrigin: true, ws: config.ws || false, pathRewrite: (reqPath, req) => rewriteRequestPath(reqPath, req, config, parseRouteUrl), logLevel: config.debug ? 'debug' : 'info', onProxyReq: (proxyReq, req, res, options) => handleProxyRequest(proxyReq, req, res, options, config, customOnProxyReq), onProxyRes: (proxyRes, req, res) => handleProxyResponse(proxyRes, req, res, renderer, config) });
404
405
  }
405
406
  /**
406
407
  * @param {AppRenderer} renderer
@@ -409,5 +410,5 @@ function createOptions(renderer, config, parseRouteUrl) {
409
410
  */
410
411
  export default function scProxy(renderer, config, parseRouteUrl) {
411
412
  const options = createOptions(renderer, config, parseRouteUrl);
412
- return proxy(options);
413
+ return createProxyMiddleware(options);
413
414
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-proxy",
3
- "version": "21.1.0-canary.99",
3
+ "version": "21.1.1",
4
4
  "description": "Proxy middleware for express.js server.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -28,15 +28,15 @@
28
28
  "url": "https://github.com/sitecore/jss/issues"
29
29
  },
30
30
  "dependencies": {
31
- "http-proxy-middleware": "^0.20.0",
31
+ "http-proxy-middleware": "^2.0.6",
32
32
  "http-status-codes": "^2.2.0",
33
33
  "set-cookie-parser": "^2.5.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/chai": "^4.3.4",
37
- "@types/http-proxy-middleware": "^0.19.3",
37
+ "@types/express": "^4.17.17",
38
38
  "@types/mocha": "^10.0.1",
39
- "@types/node": "^18.11.18",
39
+ "@types/node": "^18.14.2",
40
40
  "@types/set-cookie-parser": "^2.4.2",
41
41
  "chai": "^4.3.7",
42
42
  "del-cli": "^5.0.0",
@@ -47,7 +47,7 @@
47
47
  "typescript": "~4.9.5"
48
48
  },
49
49
  "types": "types/index.d.ts",
50
- "gitHead": "5b1755d4be55645818169d278dd204543d1351d8",
50
+ "gitHead": "ae9d7fc994fa11061b5a164ff6a86b3ccf845a4c",
51
51
  "files": [
52
52
  "dist",
53
53
  "types"
@@ -2,7 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  import { IncomingMessage, ServerResponse, Agent } from 'http';
4
4
  import { Agent as HttpsAgent } from 'https';
5
- import { Config as HttpProxyConfig } from 'http-proxy-middleware';
5
+ import { Options } from 'http-proxy-middleware';
6
6
  import { AppRenderer } from './AppRenderer';
7
7
  import { RenderResponse } from './RenderResponse';
8
8
  import { RouteUrlParser } from './RouteUrlParser';
@@ -52,7 +52,7 @@ export interface ProxyConfig {
52
52
  */
53
53
  pathRewriteExcludePredicate?: (originalUrl: string) => boolean;
54
54
  /** Configure `http-proxy-middleware` */
55
- proxyOptions?: HttpProxyConfig;
55
+ proxyOptions?: Options;
56
56
  /** Enables or disables proxy diagnostics in console.log (disable for production or get bad performance) */
57
57
  debug?: boolean;
58
58
  /** Callback when an exception is thrown during SSR; decides what to send back to client (500 errors) */
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="connect" />
3
2
  import { IncomingMessage } from 'http';
3
+ import { Request } from 'express';
4
4
  import { AppRenderer } from './AppRenderer';
5
5
  import { ProxyConfig, ServerBundle } from './ProxyConfig';
6
6
  import { RouteUrlParser } from './RouteUrlParser';
@@ -16,15 +16,15 @@ export interface ProxyIncomingMessage extends IncomingMessage {
16
16
  export declare const removeEmptyAnalyticsCookie: (proxyResponse: IncomingMessage) => void;
17
17
  /**
18
18
  * @param {string} reqPath
19
- * @param {IncomingMessage} req
19
+ * @param {Request} req
20
20
  * @param {ProxyConfig} config
21
21
  * @param {RouteUrlParser} parseRouteUrl
22
22
  */
23
- export declare function rewriteRequestPath(reqPath: string, req: IncomingMessage, config: ProxyConfig, parseRouteUrl?: RouteUrlParser): string;
23
+ export declare function rewriteRequestPath(reqPath: string, req: Request, config: ProxyConfig, parseRouteUrl?: RouteUrlParser): string;
24
24
  /**
25
25
  * @param {AppRenderer} renderer
26
26
  * @param {ProxyConfig} config
27
27
  * @param {RouteUrlParser} parseRouteUrl
28
28
  */
29
- export default function scProxy(renderer: AppRenderer, config: ProxyConfig, parseRouteUrl: RouteUrlParser): import("connect").NextHandleFunction;
29
+ export default function scProxy(renderer: AppRenderer, config: ProxyConfig, parseRouteUrl: RouteUrlParser): import("http-proxy-middleware").RequestHandler;
30
30
  export { ProxyConfig, ServerBundle };