I use orion-ld context broker
{
"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") ;
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".
Update at 03/01/2022:
Now I create a simple webpage based on JS functions from NGSI.js, as Jason Fox yesterday suggested. There you are able to test the "v2" related calls to the orion-ld and the "ld" related calls.
In the browser console, you can see the logged results.
You can also change the orion-ld URL on the website so that you can test your environment.
Nevertheless, the CORS settings for orion-ld server did not work as expected. 'v2' calls work well, 'ld' calls failed.
I create my orion-ld test environment with the following docker-compose.yml:
version: "3.5"
services:
orion-ld:
image: fiware/orion-ld
hostname: orion-ld
ports:
- "1029:1026"
depends_on:
- mongo-db
environment:
ORIONLD_CORS_ALLOWED_ORIGIN: __ALL
corsOrigin: __ALL
ORIONLD_CORS_MAX_AGE: 86400
command: -dbhost mongo-db-vm -logLevel DEBUG
mongo-db:
image: mongo:3.6
hostname: mongo-db-vm
volumes:
- /SOMEWHERE/data:/data
Please test my and your environment on simple webpage and give feedback.
Orion-LD architect and developer here. All Orion-LD has about CORS is what was inherited from Orion. This is the first time anybody asks for CORS for Orion-LD, so, I'll try to fix it asap.
I guess this is all about a local development setup. Thus you probably call your frontend at "localhost" or "127.0.0.1", leading to the CORS-issue when it calls orion at "192.168.0.18". You basically have 2 options to still make it work:
I do not think it worth implementing the CORS-support directly in Orion-LD, since this is not a real deployment scenario. In real-world scenarios, you would have one of the following: