Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate using xdomain to request sysassets files #70

Closed
neelabhg opened this issue Feb 8, 2015 · 3 comments · Fixed by #84
Closed

Investigate using xdomain to request sysassets files #70

neelabhg opened this issue Feb 8, 2015 · 3 comments · Fixed by #84
Assignees

Comments

@neelabhg
Copy link
Member

neelabhg commented Feb 8, 2015

Lesson and chapter data is available in a separate GitHub repository (https://github.com/angrave/sysassets), and published through GitHub pages (http://angrave.github.io/sysassets/). To get those resources, a cross-site request is necessary. Due to security concerns, browsers prevent cross-site requests unless the server sends some CORS headers. However, GitHub pages does not send any such headers, and so, we cannot make requests for those resources.

The current workaround is to bundle those resources with sysbuild when deploying. This approach is not good, because 1) deployment is harder (a person deploying needs to have the relevant sysassets files in their project) and 2) sysbuild needs to be deployed every time content on sysassets changes.

This comment on another issue gives more background about this problem.

xdomain is a JS library providing an alternative to CORS.
From its summary page

A pure JavaScript CORS alternative. No server configuration required - just add a proxy.html on the domain you wish to communicate with. This library utilizes XHook to hook all XHR, so XDomain will work seamlessly with any library.

This library might be a very good solution for getting files from sysassets.

@scowalt
Copy link
Contributor

scowalt commented Feb 18, 2015

I'm looking into this issue as solving this will make the development of #71 and #72 much easier. I also suspect that we may need to load subtitle through the same method.

One alternative solution to this is to use grunt-curl as a low-tech dependency manager to pull just the elements of sysassets we need. While this makes deployment easier, we would still need to re-deploy sysbuild every time we change sysassets, and thus I don't think this solution is ideal.

I've got a fork of sysassets with the xdomain proxy file included. I have a general idea of how to use xdomain. I'm working on transitioning our local file gets into web gets (i.e. $.get('sysassets/sys.min.json') into $.get('http://angrave.github.io/sysassets/sys.min.json')). When this change is ready I'll make a pull request to sysassets before I make a pull request to sysbuild to ensure the change will work immediately.

@scowalt
Copy link
Contributor

scowalt commented Feb 18, 2015

I've created a pull request to angrave/sysassets to start integrating this change.

@neelabhg
Copy link
Member Author

neelabhg commented Mar 3, 2015

Just to put it out there, using a proxy like RawGit should also solve the cross-site problem, however they are external services which do not guarantee uptime/support. It is better to avoid using an external service if possible, and so xdomain seems like the better option.

neelabhg added a commit that referenced this issue Mar 16, 2015
Issue #70: Added xdomain support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants