mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
added cache and x-requested-with header to bundle requests
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user