@zengenti/contensis-react-base 4.0.0-beta.60 → 4.0.0-beta.61
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/cjs/{App-Dr56ZsQj.js → App-TTUKj85f.js} +24 -7
- package/cjs/App-TTUKj85f.js.map +1 -0
- package/cjs/{RouteLoader-Bbt-nG3v.js → RouteLoader-BM8DyfcF.js} +5 -2
- package/cjs/RouteLoader-BM8DyfcF.js.map +1 -0
- package/cjs/client.js +2 -2
- package/cjs/contensis-react-base.js +17 -14
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/routing.js +1 -1
- package/cjs/{urls-DVIwGZmd.js → urls-DGZlAs0y.js} +3 -3
- package/cjs/urls-DGZlAs0y.js.map +1 -0
- package/cjs/util.js +2 -2
- package/esm/{App-CrCf7gso.js → App-DaHtrw85.js} +25 -8
- package/esm/App-DaHtrw85.js.map +1 -0
- package/esm/{RouteLoader-BpHhiAlL.js → RouteLoader-BwDPahRW.js} +5 -2
- package/esm/RouteLoader-BwDPahRW.js.map +1 -0
- package/esm/client.js +3 -3
- package/esm/contensis-react-base.js +18 -15
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/routing.js +1 -1
- package/esm/{urls-DfCisos-.js → urls-tLxo_skx.js} +3 -3
- package/esm/urls-tLxo_skx.js.map +1 -0
- package/esm/util.js +1 -1
- package/models/models/config/ServerConfig.d.ts +11 -0
- package/models/util/errors.d.ts +16 -0
- package/models/util/index.d.ts +1 -1
- package/models/util/urls.d.ts +1 -2
- package/package.json +1 -1
- package/cjs/App-Dr56ZsQj.js.map +0 -1
- package/cjs/RouteLoader-Bbt-nG3v.js.map +0 -1
- package/cjs/urls-DVIwGZmd.js.map +0 -1
- package/esm/App-CrCf7gso.js.map +0 -1
- package/esm/RouteLoader-BpHhiAlL.js.map +0 -1
- package/esm/urls-DfCisos-.js.map +0 -1
|
@@ -11,11 +11,13 @@ import 'deep-equal';
|
|
|
11
11
|
import 'deepmerge';
|
|
12
12
|
import 'query-string';
|
|
13
13
|
import { Op, Query } from 'contensis-core-api';
|
|
14
|
-
import { s as setCachingHeaders, u as
|
|
14
|
+
import { s as setCachingHeaders, u as urls } from './urls-tLxo_skx.js';
|
|
15
15
|
import 'isomorphic-fetch';
|
|
16
16
|
import express from 'express';
|
|
17
17
|
import http from 'http';
|
|
18
18
|
import httpProxy from 'http-proxy';
|
|
19
|
+
import { s as shorten, c as createLocaleRoutes, h as history, p as pickProject, r as rootSaga } from './App-DaHtrw85.js';
|
|
20
|
+
export { A as ReactApp } from './App-DaHtrw85.js';
|
|
19
21
|
import fs from 'fs';
|
|
20
22
|
import path from 'path';
|
|
21
23
|
import appRootPath from 'app-root-path';
|
|
@@ -28,12 +30,10 @@ import { noop, identity } from 'lodash';
|
|
|
28
30
|
import { buildCleaner } from 'lodash-clean';
|
|
29
31
|
import { a as Cookies } from './CookieHelper.class-C6rTRl_1.js';
|
|
30
32
|
import cookiesMiddleware from 'universal-cookie-express';
|
|
31
|
-
import { c as createLocaleRoutes, h as history, p as pickProject, r as rootSaga } from './App-CrCf7gso.js';
|
|
32
|
-
export { A as ReactApp } from './App-CrCf7gso.js';
|
|
33
33
|
import { c as createStore } from './store-DSjRYsM2.js';
|
|
34
34
|
import { s as setVersionStatus, c as setVersion } from './version-B75wA6Te.js';
|
|
35
35
|
import { a6 as selectSurrogateKeys, a7 as selectSsrApiCalls, j as selectRouteEntry, f as selectCurrentProject, g as getImmutableOrJS, s as setCurrentProject, F as selectCurrentSearch } from './selectors-8ROQrTd7.js';
|
|
36
|
-
import { H as HttpContext, m as mergeStaticRoutes } from './RouteLoader-
|
|
36
|
+
import { H as HttpContext, m as mergeStaticRoutes } from './RouteLoader-BwDPahRW.js';
|
|
37
37
|
import { Transform } from 'stream';
|
|
38
38
|
import { ChunkExtractor, ChunkExtractorManager } from '@loadable/server';
|
|
39
39
|
import chalk from 'chalk';
|
|
@@ -644,7 +644,7 @@ const subsiteDebugMiddleware = (subsitePath, exceptions = []) => (req, res, next
|
|
|
644
644
|
const servers$1 = SERVERS; /* global SERVERS */
|
|
645
645
|
const project = PROJECT; /* global PROJECT */
|
|
646
646
|
const alias$1 = ALIAS; /* global ALIAS */
|
|
647
|
-
const deliveryApiHostname =
|
|
647
|
+
const deliveryApiHostname = urls(alias$1, project).api;
|
|
648
648
|
const proxyTimeoutMs = 45_000;
|
|
649
649
|
const assetProxy = httpProxy.createProxyServer();
|
|
650
650
|
const deliveryProxy = httpProxy.createProxyServer();
|
|
@@ -662,13 +662,13 @@ const reverseProxies = (app, reverseProxyPaths = []) => {
|
|
|
662
662
|
});
|
|
663
663
|
});
|
|
664
664
|
assetProxy.on('error', (e, req) => {
|
|
665
|
-
console.log(`
|
|
665
|
+
console.log(`[assetProxy] "${req.method} ${req.url}" host: ${req.headers.host} failed with ${e}`);
|
|
666
666
|
});
|
|
667
667
|
};
|
|
668
668
|
const deliveryApiProxy = (apiProxy, app) => {
|
|
669
669
|
// This is just here to stop cors requests on localhost. In Production this is mapped using varnish.
|
|
670
670
|
app.all(['/api/delivery/{*splat}', '/api/forms/{*splat}', '/api/image/{*splat}', '/authenticate/{*splat}'], (req, res) => {
|
|
671
|
-
console.log(`
|
|
671
|
+
console.log(`[apiProxy] "${req.method} ${shorten(req.url)}" target: ${servers$1.alias}`);
|
|
672
672
|
apiProxy.web(req, res, {
|
|
673
673
|
target: deliveryApiHostname,
|
|
674
674
|
changeOrigin: true,
|
|
@@ -677,7 +677,7 @@ const deliveryApiProxy = (apiProxy, app) => {
|
|
|
677
677
|
});
|
|
678
678
|
});
|
|
679
679
|
apiProxy.on('error', (e, req) => {
|
|
680
|
-
console.log(`
|
|
680
|
+
console.log(`[apiProxy] "${req.method} ${req.url}" host: ${req.headers.host} failed with ${e}`);
|
|
681
681
|
});
|
|
682
682
|
};
|
|
683
683
|
|
|
@@ -883,9 +883,11 @@ const renderStream = (getContextHtml, jsx, request, response, stream) => {
|
|
|
883
883
|
},
|
|
884
884
|
onShellError(error) {
|
|
885
885
|
abortCleanup(error); // Abnormal - destroy everything
|
|
886
|
-
response.
|
|
887
|
-
|
|
888
|
-
|
|
886
|
+
if (!response.headersSent) {
|
|
887
|
+
response.statusCode = 500;
|
|
888
|
+
response.setHeader('content-type', 'text/html; charset=utf-8');
|
|
889
|
+
response.send('<h1>Something went wrong</h1>');
|
|
890
|
+
}
|
|
889
891
|
console.error(`[renderToPipeableStream:onShellError]`, error);
|
|
890
892
|
},
|
|
891
893
|
onError(error) {
|
|
@@ -1117,6 +1119,7 @@ const unhandledExceptionHandler = (handleExceptions = handleDefaultEvents) => {
|
|
|
1117
1119
|
}
|
|
1118
1120
|
};
|
|
1119
1121
|
|
|
1122
|
+
const logPrefix = '[addHeaders]';
|
|
1120
1123
|
const addStandardHeaders = (state, response, packagejson, groups) => {
|
|
1121
1124
|
if (state) {
|
|
1122
1125
|
try {
|
|
@@ -1130,14 +1133,14 @@ const addStandardHeaders = (state, response, packagejson, groups) => {
|
|
|
1130
1133
|
// - add `any-update` header that will indiscriminately
|
|
1131
1134
|
// invalidate the SSR page cache when any content is updated
|
|
1132
1135
|
const addAnyUpdateHeader = routingSurrogateKeys.length >= 2000 || response.statusCode >= 400 || anyApiError;
|
|
1133
|
-
console.info(
|
|
1136
|
+
console.info(`${logPrefix} ${addAnyUpdateHeader ? anyUpdateHeader : routingSurrogateKeys.length} surrogate keys for ${response.req.url}`);
|
|
1134
1137
|
const surrogateKeys = addAnyUpdateHeader ? anyUpdateHeader : routingSurrogateKeys.join(' ');
|
|
1135
1138
|
const surrogateKeyHeader = `${packagejson.name}-app ${surrogateKeys}`;
|
|
1136
1139
|
response.setHeader('surrogate-key', surrogateKeyHeader);
|
|
1137
1140
|
addVarnishAuthenticationHeaders(state, response, groups);
|
|
1138
1141
|
response.setHeader('surrogate-control', `max-age=${getCacheDuration(response.statusCode)}`);
|
|
1139
1142
|
} catch (e) {
|
|
1140
|
-
console.info(
|
|
1143
|
+
console.info(`${logPrefix} Error adding headers`, e.message);
|
|
1141
1144
|
}
|
|
1142
1145
|
}
|
|
1143
1146
|
};
|
|
@@ -1156,7 +1159,7 @@ const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
|
|
|
1156
1159
|
}
|
|
1157
1160
|
response.header('x-contensis-viewer-groups', allGroups.join('|'));
|
|
1158
1161
|
} catch (e) {
|
|
1159
|
-
console.info(
|
|
1162
|
+
console.info(`${logPrefix} Error adding authentication header`, e);
|
|
1160
1163
|
}
|
|
1161
1164
|
}
|
|
1162
1165
|
};
|
|
@@ -1355,7 +1358,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
1355
1358
|
const hostname = request.headers['x-orig-host'] || request.hostname;
|
|
1356
1359
|
const subsitePath = getSubsitePath(request);
|
|
1357
1360
|
const subsitePathScript = subsitePath ? `window.subsitePath = ${serialize(subsitePath)};` : '';
|
|
1358
|
-
console.info(`
|
|
1361
|
+
console.info(`[webApp] "${request.method} ${request.path}" hostname: ${hostname} versionStatus: ${versionStatus}`);
|
|
1359
1362
|
store.dispatch(setVersionStatus(versionStatus));
|
|
1360
1363
|
store.dispatch(setVersion(versionInfo.commitRef, versionInfo.buildNo));
|
|
1361
1364
|
const project = pickProject(hostname, request.query);
|