@zengenti/contensis-react-base 4.0.0-beta.56 → 4.0.0-beta.58

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.
@@ -662,6 +662,7 @@ const servers$1 = SERVERS; /* global SERVERS */
662
662
  const project = PROJECT; /* global PROJECT */
663
663
  const alias$1 = ALIAS; /* global ALIAS */
664
664
  const deliveryApiHostname = urls.url(alias$1, project).api;
665
+ const proxyTimeoutMs = 45_000;
665
666
  const assetProxy = httpProxy__default.default.createProxyServer();
666
667
  const deliveryProxy = httpProxy__default.default.createProxyServer();
667
668
  const reverseProxies = (app, reverseProxyPaths = []) => {
@@ -669,15 +670,17 @@ const reverseProxies = (app, reverseProxyPaths = []) => {
669
670
  app.all(reverseProxyPaths.map(proxyPath =>
670
671
  // Patch to update paths for express v5
671
672
  proxyPath.endsWith('/*') ? `${proxyPath.slice(0, -2)}/{*splat}` : proxyPath.endsWith('/**') ? `${proxyPath.slice(0, -3)}/{*splat}` : proxyPath), (req, res) => {
672
- const target = req.hostname.indexOf('preview-') || req.hostname.indexOf('preview.') || req.hostname === 'localhost' ? servers$1.previewIis || servers$1.iis : servers$1.iis;
673
+ const target = req.hostname.includes('preview-') || req.hostname.includes('preview.') || req.hostname === 'localhost' ? servers$1.previewIis || servers$1.iis : servers$1.iis;
673
674
  assetProxy.web(req, res, {
674
675
  target,
675
- changeOrigin: true
676
- });
677
- assetProxy.on('error', e => {
678
- console.log(`Proxy Request for ${req.path} HostName:${req.hostname} failed with ${e}`);
676
+ changeOrigin: true,
677
+ proxyTimeout: proxyTimeoutMs,
678
+ timeout: proxyTimeoutMs
679
679
  });
680
680
  });
681
+ assetProxy.on('error', (e, req) => {
682
+ console.log(`Proxy request for ${req.url} HostName:${req.headers.host} failed with ${e}`);
683
+ });
681
684
  };
682
685
  const deliveryApiProxy = (apiProxy, app) => {
683
686
  // This is just here to stop cors requests on localhost. In Production this is mapped using varnish.
@@ -685,12 +688,14 @@ const deliveryApiProxy = (apiProxy, app) => {
685
688
  console.log(`Proxying api request to ${servers$1.alias}`);
686
689
  apiProxy.web(req, res, {
687
690
  target: deliveryApiHostname,
688
- changeOrigin: true
689
- });
690
- apiProxy.on('error', e => {
691
- console.log(`Proxy request for ${req.path} HostName:${req.hostname} failed with ${e}`);
691
+ changeOrigin: true,
692
+ proxyTimeout: proxyTimeoutMs,
693
+ timeout: proxyTimeoutMs
692
694
  });
693
695
  });
696
+ apiProxy.on('error', (e, req) => {
697
+ console.log(`Proxy request for ${req.url} HostName:${req.headers.host} failed with ${e}`);
698
+ });
694
699
  };
695
700
 
696
701
  const CacheDuration = {