Skip to content

Commit 0362a0f

Browse files
xitij2000navinkarkera
authored andcommitted
fix: loading of underscore and other text assets over CDN
The text plugin for requirejs is used to load text assets such as .underscore files. To avoid CORS issues when loading such assets from a different domain, such as a when a CDN is in use, this plugin loads such assets as .js files by adding a script tag. What this means in practice is that if you configure the platform to serve static assets from a CDN, it will try to load `file.underscore.js` instead of `file.underscore`. We can override this behaviour by providing a `useXhr` function for the text plugin configuration. The plugin will use this function to determine whether to use XHR or the script tag approach. In this change we are asking it to always use XHR since the concerns about CORS raised by the plugins documentation don't apply here. ref: https://github.com/requirejs/text/blob/3f9d4c19b3a1a3c6f35650c5788cbea1db93197a/README.md#xhr-restrictions
1 parent 98944d2 commit 0362a0f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

cms/static/cms/js/require-config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@
353353
'jquery_extend_patch': {
354354
deps: ['jquery']
355355
}
356+
},
357+
config: {
358+
text: {
359+
useXhr: () => true
360+
}
356361
}
357362
});
358363
}).call(this, require, define);

lms/static/lms/js/require-config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@
226226
'hls': {
227227
exports: 'Hls'
228228
}
229+
},
230+
config: {
231+
text: {
232+
useXhr: () => true
233+
}
229234
}
230235
});
231236
}).call(this, require || RequireJS.require, define || RequireJS.define);

0 commit comments

Comments
 (0)