Dojo: custom assembly hosted externally, locale error

I created a custom assembly using the Dojo assembly tool, including all the modules I use. This works great. However, now that I have moved this assembly to the CDN, I get an access control error when I try to load the locale file:

XMLHttpRequest cannot load http://<CDN domain>/js/release/dojo/dojo/nls/custom-dojo_en-gb.js. Origin <site domain> is not allowed by Access-Control-Allow-Origin Uncaught Error: Could not load 'dojo.nls.custom-dojo_en-gb'; last tried './nls/custom-dojo_en-gb.js' 

How can I make him download this file from the CDN domain? Or if this fails, can I add a cross-domain file so that it can be downloaded from the main domain?

+4
source share
1 answer

To fix this, RTFM was a little closer for me! You can pass loader = xdomain to the build tool along with the domain you want to bake in the assembly. Then you refer to dojo.xd.js instead of dojo.js, and everything works fine:

 ./build.sh profileFile=/path/to/profile.js action=clean,release loader=xdomain xdDojoPath=http://cdndomain/js/release/dojo releaseDir=/path/to/release 
+5
source

Source: https://habr.com/ru/post/1345238/


All Articles