logo hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    JavaScript Project Info Getter: Same Origin Policy Block

    Scheduled Pinned Locked Moved
    General Discussion
    help website
    2
    3
    841
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • KamdroidK
      Kamdroid
      last edited by

      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).

      1 Reply Last reply Reply Quote 0
      • HamedH
        Hamed Admin
        last edited by

        @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:

        http://anyorigin.com/

        KamdroidK 1 Reply Last reply Reply Quote 0
        • KamdroidK
          Kamdroid @Hamed
          last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post