You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Orion-LD上下文代理CORS配置异常排查:JS调用NGSI-LD接口遭跨域拦截问题

Orion-LD CORS Policy Issue: LD Endpoints Fail Despite __ALL Origin Setting

Environment Details

My Orion-LD context broker setup has the following details:

{
  "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/"
}

Problem Description

When making a client-side XMLHttpRequest to an NGSI-LD endpoint, I'm hitting a CORS policy block:

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.

Oddly enough, v2 API calls work perfectly fine with the same CORS setup, but all LD endpoint requests fail with the above error.

Reproduction Code

Here's the client-side JS code triggering the error:

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();

Troubleshooting Steps Taken

  • Verified Docker Environment Variables: My docker-compose.yml explicitly sets CORS-related variables for Orion-LD:
    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
    
  • Checked Container Variables: I logged into the Orion-LD Docker container console and confirmed ORIONLD_CORS_ALLOWED_ORIGIN is set to "__ALL".
  • Tested with NGSI.js-Based Page: Following a suggestion from Jason Fox (Jan 2, 2022), I built a simple test page using NGSI.js functions to test both v2 and LD endpoints. The v2 calls succeed, but LD calls still fail with the same CORS error.

Request for Assistance

Could someone help troubleshoot this discrepancy? I'd appreciate it if you could test this scenario in your own Orion-LD environment and share your findings, or suggest additional steps to diagnose why the CORS settings aren't applying to LD endpoints.


内容的提问来源于stack exchange,提问作者knigge

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 14:47:36