Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-19269

FIWARE.Question.Tech.JS can't receive JSON data from orion-ld broker, a CORS related issue occurred.

    Details

      Description

      Created question in FIWARE Q/A platform on 27-02-2022 at 08:02
      Please, ANSWER this question AT https://stackoverflow.com/questions/71283416/js-cant-receive-json-data-from-orion-ld-broker-a-cors-related-issue-occurred

      Question:
      JS can't receive JSON data from orion-ld broker, a CORS related issue occurred

      Description:
      I use orion-ld context brocker
      {
      "orionld version": "post-v1.0.0",
      "orion version": "1.15.0-next",
      "uptime": "0 d, 0 h, 25 m, 17 s",
      "git_hash": "nogitversion",
      "compile_time": "Wed Jan 26 15:58:47 UTC 2022",
      "compiled_by": "root",
      "compiled_in": "",
      "release_date": "Wed Jan 26 15:58:47 UTC 2022",
      "doc": "https://fiware-orion.readthedocs.org/en/master/"
      }

      If I try to request JSON data in an HTML file via JS like
      var myRequest = new XMLHttpRequest();
      myRequest.open("GET", "http://192.168.0.18:1028/ngsi-ld/v1/entities/urn:ngsi-ld:OffStreetParking:XXX_102700&quot ;
      myRequest.setRequestHeader("Accept", "application/ld+json")
      myRequest.onload = function () {
      console.log(myRequest.responseText);
      };
      myRequest.send();

      I got a error: "Access to XMLHttpRequest at 'http://192.168.0.18:1028/ngsi-ld/v1/entities/urn:ngsi-ld:OffStreetParking:XXX_102700' from origin 'http://192.168.0.18' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."
      If I login to the docker container console and check the variable ORIONLD_CORS_ALLOWED_ORIGIN, it contains the necessary value "__ALL".
      What could be wrong here?

        Activity

          People

          • Assignee:
            stefan.wiedemann Stefan Wiedemann
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: