JavaScript Project Info Getter: Same Origin Policy Block



  • So, I would like to make a script that can retrieve information about my projects through their URL using JavaScript/jQuery, so I can display it on my website.

    However, I cannot figure out how to get around the Same Origin Policy that prevents me from getting the HTML from my project's page so I can parse the information from it.

    Is there any way this could be allowed, or is there a better way that works which I am not aware of?

    Better yet, it would be great to have access to my account's projects, so I could even dynamically load in the projects so there is no manual updating when I release a new project.

    The only solution I am aware of is by using some sort of server-side solution, but unfortunately I may not be able to do this due to the costs.

    $.get('https://www.hyperpad.com/projects/asudb1ye/versions/simple-calculator', function(data) {
      // ...
    });
    

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.hyperpad.com/projects/asudb1ye/versions/simple-calculator. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).


  • Admin

    @Kamdroid this is a browser security issue. You would need some server side mechanism to do this for you.

    Here is a tool that you can use to circumvent this:



  • @hamed Thanks. Yea, I saw some CORS proxies yesterday.

    However, some websites allow CORS which lets the browser get the data.

    I am pretty sure it is done via a header on the server: https://enable-cors.org/server.html

    The proxy works fine, but it would be faster to directly get the hyperPad HTML, and more stable as you don't rely on a third-party to retrieve the HTML.

    For now I'll be using a proxy by default, if the CORS is ever allowed it'd be great.

    I should be releasing my hyperPad info grabber library in a few weeks or so.