@redhat-cloud-services/frontend-components-config-utilities 4.12.0 → 4.12.2
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/package.json +1 -1
- package/proxy.js +19 -1
package/package.json
CHANGED
package/proxy.js
CHANGED
|
@@ -141,6 +141,7 @@ var buildLocalAppRoutes = function (localApps, defaultLocalAppHost, target) {
|
|
|
141
141
|
var proxy = function (_a) {
|
|
142
142
|
var _b = _a.env, env = _b === void 0 ? 'stage-stable' : _b, _c = _a.customProxy, customProxy = _c === void 0 ? [] : _c, routes = _a.routes, routesPath = _a.routesPath, useProxy = _a.useProxy, _d = _a.proxyURL, proxyURL = _d === void 0 ? 'http://squid.corp.redhat.com:3128' : _d, _e = _a.appUrl, appUrl = _e === void 0 ? [] : _e, publicPath = _a.publicPath, proxyVerbose = _a.proxyVerbose, _f = _a.useCloud, useCloud = _f === void 0 ? false : _f, _g = _a.target, target = _g === void 0 ? '' : _g, _h = _a.bounceProd, bounceProd = _h === void 0 ? false : _h, _j = _a.useAgent, useAgent = _j === void 0 ? true : _j, _k = _a.localApps, localApps = _k === void 0 ? process.env.LOCAL_APPS : _k, _l = _a.frontendCRDPath, frontendCRDPath = _l === void 0 ? path_1.default.resolve(process.cwd(), 'deploy/frontend.yaml') : _l;
|
|
143
143
|
var frontendCrdRef = { current: undefined };
|
|
144
|
+
var triggerReload;
|
|
144
145
|
var FEOFeaturesEnabled = false;
|
|
145
146
|
try {
|
|
146
147
|
frontendCrdRef.current = (0, crd_check_1.readFrontendCRD)(frontendCRDPath);
|
|
@@ -158,6 +159,7 @@ var proxy = function (_a) {
|
|
|
158
159
|
(0, fec_logger_1.default)(fec_logger_1.LogType.info, 'Frontend CRD has changed, reloading the file');
|
|
159
160
|
try {
|
|
160
161
|
frontendCrdRef.current = (0, crd_check_1.readFrontendCRD)(frontendCRDPath);
|
|
162
|
+
triggerReload === null || triggerReload === void 0 ? void 0 : triggerReload();
|
|
161
163
|
}
|
|
162
164
|
catch (error) {
|
|
163
165
|
(0, fec_logger_1.default)(fec_logger_1.LogType.error, 'Error reloading frontend CRD file', error);
|
|
@@ -215,8 +217,16 @@ var proxy = function (_a) {
|
|
|
215
217
|
proxy.push.apply(proxy, customProxy);
|
|
216
218
|
}
|
|
217
219
|
if (useProxy) {
|
|
218
|
-
proxy.push(__assign({ secure: false, changeOrigin: true, autoRewrite: true,
|
|
220
|
+
proxy.push(__assign({ secure: false, changeOrigin: true, autoRewrite: true, onProxyReq: function (proxyReq, req) {
|
|
219
221
|
if (FEOFeaturesEnabled && frontendCrdRef.current && (0, check_outgoing_requests_1.isInterceptAbleRequest)(req.url)) {
|
|
222
|
+
proxyReq.removeHeader('if-none-match');
|
|
223
|
+
proxyReq.removeHeader('if-modified-since');
|
|
224
|
+
}
|
|
225
|
+
}, onProxyRes: function (proxyRes, req, res) {
|
|
226
|
+
if (FEOFeaturesEnabled && frontendCrdRef.current && (0, check_outgoing_requests_1.isInterceptAbleRequest)(req.url)) {
|
|
227
|
+
res.removeHeader('etag');
|
|
228
|
+
res.removeHeader('last-modified');
|
|
229
|
+
res.setHeader('cache-control', 'no-store, no-cache, must-revalidate');
|
|
220
230
|
var _write_1 = res.write;
|
|
221
231
|
var body_1 = '';
|
|
222
232
|
proxyRes.on('data', function (chunk) {
|
|
@@ -290,6 +300,14 @@ var proxy = function (_a) {
|
|
|
290
300
|
})));
|
|
291
301
|
}
|
|
292
302
|
var config = __assign(__assign({}, (proxy.length > 0 && { proxy: proxy })), { onListening: function (server) {
|
|
303
|
+
if (FEOFeaturesEnabled) {
|
|
304
|
+
triggerReload = function () {
|
|
305
|
+
var _a;
|
|
306
|
+
if ((_a = server.webSocketServer) === null || _a === void 0 ? void 0 : _a.clients) {
|
|
307
|
+
server.sendMessage(server.webSocketServer.clients, 'content-changed');
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
293
311
|
if (useProxy) {
|
|
294
312
|
var host = useProxy ? "".concat(majorEnv === 'dev' ? 'prod' : majorEnv, ".foo.redhat.com") : 'localhost';
|
|
295
313
|
var origin_1 = "https://".concat(host, ":").concat(server.options.port);
|