fix: loading of underscore and other text assets over CDN #586
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of openedx#33124
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 offile.underscore
. We can override this behaviour by providing auseXhr
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