@zengenti/contensis-react-base 3.0.1-beta.2 → 3.0.1-beta.4

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.
@@ -14,7 +14,7 @@ require('query-string');
14
14
  require('immer');
15
15
  require('deep-equal');
16
16
  var contensisCoreApi = require('contensis-core-api');
17
- var setCachingHeaders = require('./setCachingHeaders-ee619bdf.js');
17
+ var urls = require('./urls-6fcaf4c6.js');
18
18
  require('isomorphic-fetch');
19
19
  var express = require('express');
20
20
  var httpProxy = require('http-proxy');
@@ -638,7 +638,7 @@ const makeLinkDepthMiddleware = ({
638
638
  const linkDepthMiddleware = async (req, res) => {
639
639
  try {
640
640
  // Short cache duration copied from canterbury project
641
- setCachingHeaders.setCachingHeaders(res, {
641
+ urls.setCachingHeaders(res, {
642
642
  cacheControl: 'private',
643
643
  surrogateControl: '10'
644
644
  }); // Gather all params from the request, we will use them at the right query levels later
@@ -700,17 +700,25 @@ const DisplayStartupConfiguration = config => {
700
700
  const servers = SERVERS;
701
701
  /* global SERVERS */
702
702
 
703
- const apiProxy = httpProxy__default["default"].createProxyServer();
703
+ const project = PROJECT;
704
+ /* global PROJECT */
705
+
706
+ const alias = ALIAS;
707
+ /* global ALIAS */
708
+
709
+ const deliveryApiHostname = urls.url(alias, project).api;
710
+ const assetProxy = httpProxy__default["default"].createProxyServer();
711
+ const deliveryProxy = httpProxy__default["default"].createProxyServer();
704
712
 
705
713
  const reverseProxies = (app, reverseProxyPaths = []) => {
706
- deliveryApiProxy(apiProxy, app);
714
+ deliveryApiProxy(deliveryProxy, app);
707
715
  app.all(reverseProxyPaths, (req, res) => {
708
716
  const target = req.hostname.indexOf('preview-') || req.hostname.indexOf('preview.') || req.hostname === 'localhost' ? servers.previewIis || servers.iis : servers.iis;
709
- apiProxy.web(req, res, {
717
+ assetProxy.web(req, res, {
710
718
  target,
711
719
  changeOrigin: true
712
720
  });
713
- apiProxy.on('error', e => {
721
+ assetProxy.on('error', e => {
714
722
  /* eslint-disable no-console */
715
723
  console.log(`Proxy Request for ${req.path} HostName:${req.hostname} failed with ${e}`);
716
724
  /* eslint-enable no-console */
@@ -722,10 +730,9 @@ const deliveryApiProxy = (apiProxy, app) => {
722
730
  // This is just here to stop cors requests on localhost. In Production this is mapped using varnish.
723
731
  app.all(['/api/delivery/*', '/api/image/*'], (req, res) => {
724
732
  /* eslint-disable no-console */
725
- const target = servers.cms;
726
733
  console.log(`Proxying api request to ${servers.alias}`);
727
734
  apiProxy.web(req, res, {
728
- target,
735
+ target: deliveryApiHostname,
729
736
  changeOrigin: true
730
737
  });
731
738
  apiProxy.on('error', e => {
@@ -4401,7 +4408,7 @@ const start = (ReactApp, config, ServerFeatures) => {
4401
4408
 
4402
4409
  var internalServer = {
4403
4410
  app,
4404
- apiProxy,
4411
+ apiProxy: deliveryProxy,
4405
4412
  start
4406
4413
  };
4407
4414