@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.
@@ -644,6 +644,7 @@ const servers$1 = SERVERS; /* global SERVERS */
644
644
  const project = PROJECT; /* global PROJECT */
645
645
  const alias$1 = ALIAS; /* global ALIAS */
646
646
  const deliveryApiHostname = url(alias$1, project).api;
647
+ const proxyTimeoutMs = 45_000;
647
648
  const assetProxy = httpProxy.createProxyServer();
648
649
  const deliveryProxy = httpProxy.createProxyServer();
649
650
  const reverseProxies = (app, reverseProxyPaths = []) => {
@@ -651,15 +652,17 @@ const reverseProxies = (app, reverseProxyPaths = []) => {
651
652
  app.all(reverseProxyPaths.map(proxyPath =>
652
653
  // Patch to update paths for express v5
653
654
  proxyPath.endsWith('/*') ? `${proxyPath.slice(0, -2)}/{*splat}` : proxyPath.endsWith('/**') ? `${proxyPath.slice(0, -3)}/{*splat}` : proxyPath), (req, res) => {
654
- const target = req.hostname.indexOf('preview-') || req.hostname.indexOf('preview.') || req.hostname === 'localhost' ? servers$1.previewIis || servers$1.iis : servers$1.iis;
655
+ const target = req.hostname.includes('preview-') || req.hostname.includes('preview.') || req.hostname === 'localhost' ? servers$1.previewIis || servers$1.iis : servers$1.iis;
655
656
  assetProxy.web(req, res, {
656
657
  target,
657
- changeOrigin: true
658
- });
659
- assetProxy.on('error', e => {
660
- console.log(`Proxy Request for ${req.path} HostName:${req.hostname} failed with ${e}`);
658
+ changeOrigin: true,
659
+ proxyTimeout: proxyTimeoutMs,
660
+ timeout: proxyTimeoutMs
661
661
  });
662
662
  });
663
+ assetProxy.on('error', (e, req) => {
664
+ console.log(`Proxy request for ${req.url} HostName:${req.headers.host} failed with ${e}`);
665
+ });
663
666
  };
664
667
  const deliveryApiProxy = (apiProxy, app) => {
665
668
  // This is just here to stop cors requests on localhost. In Production this is mapped using varnish.
@@ -667,12 +670,14 @@ const deliveryApiProxy = (apiProxy, app) => {
667
670
  console.log(`Proxying api request to ${servers$1.alias}`);
668
671
  apiProxy.web(req, res, {
669
672
  target: deliveryApiHostname,
670
- changeOrigin: true
671
- });
672
- apiProxy.on('error', e => {
673
- console.log(`Proxy request for ${req.path} HostName:${req.hostname} failed with ${e}`);
673
+ changeOrigin: true,
674
+ proxyTimeout: proxyTimeoutMs,
675
+ timeout: proxyTimeoutMs
674
676
  });
675
677
  });
678
+ apiProxy.on('error', (e, req) => {
679
+ console.log(`Proxy request for ${req.url} HostName:${req.headers.host} failed with ${e}`);
680
+ });
676
681
  };
677
682
 
678
683
  const CacheDuration = {