开发者

Dojo: custom build hosted externally, locale error

I've created a custom build using the Dojo build tool including all the modules I'm using. This works great. However now that I've moved that build onto a CDN I'm getting an access control error when it tries to load the locale file:

开发者_StackOverflow
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 get it to load that file from the CDN domain instead? Or failing that, can I add a cross domain file to allow it to be loaded from the main domain?


The fix for this was for me to RTFM a little more closely! You can pass loader=xdomain to the build tool, along with the domain you want to bake into the build. You then reference dojo.xd.js instead of dojo.js and everything works great:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜