From 8035587f6fdcf69d50103245f0756e41eb6af536 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Tue, 22 Oct 2019 14:00:43 +0200 Subject: [PATCH 1/3] added cache and x-requested-with header to bundle requests --- scm-ui/ui-webapp/src/containers/loadBundle.ts | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/scm-ui/ui-webapp/src/containers/loadBundle.ts b/scm-ui/ui-webapp/src/containers/loadBundle.ts index 0a7c6af01b..d0a654afb3 100644 --- a/scm-ui/ui-webapp/src/containers/loadBundle.ts +++ b/scm-ui/ui-webapp/src/containers/loadBundle.ts @@ -18,19 +18,42 @@ import * as UIExtensions from "@scm-manager/ui-extensions"; import * as UIComponents from "@scm-manager/ui-components"; import { urls } from "@scm-manager/ui-components"; -// TODO add headers "Cache": "no-cache", "X-Requested-With": "XMLHttpRequest" +type PluginModule = { + name: string; + address: string; +}; + +const BundleLoader = { + name: "bundle-loader", + fetch: (plugin: PluginModule) => { + return fetch(plugin.address, { + credentials: "same-origin", + headers: { + Cache: "no-cache", + // identify the request as ajax request + "X-Requested-With": "XMLHttpRequest" + } + }).then(response => { + return response.text(); + }); + } +}; + +SystemJS.registry.set(BundleLoader.name, SystemJS.newModule(BundleLoader)); SystemJS.config({ baseURL: urls.withContextPath("/assets"), meta: { "/*": { + // @ts-ignore typing missing, but seems required esModule: true, - authorization: true + authorization: true, + loader: BundleLoader.name } } }); -const expose = (name, cmp, defaultCmp) => { +const expose = (name: string, cmp: any, defaultCmp?: any) => { let mod = cmp; if (defaultCmp) { // SystemJS default export: @@ -55,4 +78,4 @@ expose("query-string", QueryString, QueryStringDefault); expose("@scm-manager/ui-extensions", UIExtensions); expose("@scm-manager/ui-components", UIComponents); -export default plugin => SystemJS.import(plugin); +export default (plugin: string) => SystemJS.import(plugin); From 6da13b651c2bf81971916a30dc2fe5dc66b7a8f7 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 23 Oct 2019 15:35:25 +0200 Subject: [PATCH 2/3] try to fix ci build, by adding name root to top package.json see https://github.com/lerna/lerna/issues/1835 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 1085200e2a..b2f14826c5 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "name": "root", "private": true, "workspaces": [ "scm-ui/*", From e0a7952e693be2f619f0239c8947cdbbe3311b74 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Thu, 24 Oct 2019 08:29:49 +0000 Subject: [PATCH 3/3] Close branch bugifx/missing_x_requested_with_header