OH3 Rest-API CORS or not to CORS

Dear OH Community,

HAPPY NEW YEAR and THANK YOU for continuously improving OpenHAB.

I am just migrating to OH3 and since I am having my own mobile enabled dashboard (AngularJS via API) I heavily rely on the OH3 API.

Where I get stuck is that my own dashboard complains about CORS policy

Access to XMLHttpRequest at 'http://172.27.1.31/rest/items/Netatmo_Outdoor_Temperature' from origin 'http://172.27.1.30' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Yet, I added the CORS enabled=true (that I used in OH2.5) to /conf/services/runtime.cfg

org.eclipse.smarthome.cors:enable=true

Maybe this is not the way that I am supposed to do this anymore, thus would be happy for help (did search the community, but not find it, so wondering if I do anything wrong the way I access the API that CORS comes to play at all).

If I open the API in my browser I can see all items and their values perfectly - only if I open the API from AngularJS I get this error message.

I do not do a ton of web development these days, and never really looked closely into CORS,… please excuse if it is a stupid approach :slight_smile:

Best
Jens

I do not know, but try

org.openhab.cors:enable=true
2 Likes

Hi Bruce,

thx it works - this was too obvious, should have seen that myself :roll_eyes:

Anyhow thx for pointing it out :slight_smile:

Would still be interested if there is a way w/o using the CORS enabled parameter.

Best

  • Jens