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

    JavaScript Project Info Getter: Same Origin Policy Block

    Scheduled Pinned Locked Moved General Discussion
    helpwebsite
    3 Posts 2 Posters 1.3k Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post