Maker API CORS error?

i'm trying to write some frontend code using maker API and when I do a get or a post, i get a CORS error. code is running on localhost . i tried hitting against my local and against the cloud api - same result.
what's the recommended way to access the api from a JavaScript app?

really ? no one had this issue except me?

Certainly not the only one. This thread has had a little discussion Cross origin.

Would help to have more info on what you are trying to do. I've managed to work this using a node package
http-cors-proxy - npm that creates a proxy address and works for my experiments.

There is also a chrome extension that helps with issues if you are working direct from the browser. Allow CORS: Access-Control-Allow-Origin - Chrome Web Store

Hope these help - others much more knowledgable can comment and there's a lot of advice to be found out there - Google is a friend.

well, the issue for me is i'm trying to do this server-less... at least for now. just static files are sufficient to do what I need, so as such, i can't do a proxy or the like. wish i could configure maker api to add domains or ignore cross-origin

A fix has been submitted for Maker API to allow local access to the endpoints with a configurable list of hosts to allow.

1 Like

Awesome! When will it be available for general consumption?

We don't give ETAs on software releases. Not sure if it will make it in the next version or not. When I know, I will update.

1 Like

fantastic! thanks for the quick update

That sounds great!

Thanks.

Great news ( Thank you Hubitat !) Today's release.

  • Maker API added optional CORS support by host name for LAN connections only.

Any pointers as to how we implement this? Thanks for incorporating - will save some of the hoops I've been jumping through when I play with this...

Add the hosts you want in the app

This will only work with local LAN connections.

3 Likes

Is there a proper way to update the maker app short of removing/reinstalling and then reenabling devices?

Do I really need to list the many devices in my house (AKA, repurposed smartphones) that need access?

I'm running my own shim (proxy) but it would be nice to go direct.

Wonderful.

Thank you.

You just go into the app and select or change what you need to and click done.

does it support wild cards? I am running off a local unhosted static file (just opening an html file from a browser). So in this case, i'd like to just add * or something of the sort.. or 192.168.. ?

1 Like

I don't know. Can't hurt to try. Let me know what you find out.

Hope you figured this out what to put into Maker's CORS data.

I'm testing an internet Simulated Keypad device that I'm converting from ST and decided to use Maker API. Keep getting a Javascript CORS error, no matter what I put into the Cors field: local host, my internet IP address, my computer's local address 192.168.0.101 i'm out of ideas. Testing app with Cloud url with this url using a wampserver

http://192.168.0.101/cz/keypadHE/www/

javascript error
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cloud.hubitat.com/api/[token]/apps/1174/devices/481/version/?access_token=[token]. (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘'https://www.arnb.org', http://192.168.0.101’)

When I use a browser command line with the url it works as expected.

The CORS I received error was created by Firefox's javascript, the message was never sent. For the moment, I am using the CORS Everywhere as a workaround.

Oh well now the message is getting blocked at the Hubitat server for a Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘'http:192.168.0.101','http://localhost/cz/*'’).

So I hope someone knows the secret handshake for getting around this one.

Thanks

The maker API is now taking very long and timing out when I a request using WebFetch. I added my LIFX bulbs and now have 106 device. What can I do?

Not sure... Depends on the request you are trying to make. LIFX drivers aren't built in, so it could be a driver problem. Does loading one device act slow, or is it just getting the list of devices?

Download the Hubitat app