Javascript fetch request #16
Replies: 2 comments
|
From the error message, it seems like you are making a get call without setting the origin as it says |
|
Thank you @mehdyouras . The issue is that I am making the call from a browser. What would I set as the origin? As far as I understand the origin can only be set for a server side call. I believe that Postman is using a proxy in the background which is why this works. However, I am not a developer. I may be wrong and any input is appreciated. Alternatively, would you consider allowing known home automation dashboard domains? I am trying to display the pool information on sharptools and the origin would be "https://run.sharptools.app". I believe this is something many others would use. similar to actiontiles and similar tools. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I want to query the pool api from a browser but I keep receiving a CORS policy error:
Access to fetch at 'https://api.iopool.com/v1/pools' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.It seems the only solution is to use a proxy or write a backend function but that does not solve my problem. Is there any way to make that API call from a browser?
I am following these directions:
https://community.homey.app/t/api-request-with-headers/65677
The same API call works in postman btw but not in the browser.
Alternatively or even better would be an integration with smartthings.
Thanks!
All reactions