Hexagon / entsoe-api-client

ENTSO-e transparency platform API Client built for Deno. Complete. Easy to use. Minimal.
https://entsoe-api-client.56k.guru
MIT License
11 stars 1 forks source link

CORS issue #3

Open roestigraben opened 1 year ago

roestigraben commented 1 year ago

I have the package working very fine on Postman as well as in my app provided for I use the CORS plugin on Chrome. So essentially I believe I have a problem with CORS. This plugin on Chrome is not recommendable for other than a quick and dirty check.

When I don't use the plugin, I get a error message in the console:

Uncaught (in promise) TypeError: Failed to fetch at Query......

when I follow the link of the failure, I see that it points to the fetch command const result = await fetch(${ENTSOE_ENDPOINT}?${query})

I am trying since > 1 day to resolve but I am not able.

Hexagon commented 1 year ago

Oh, are you running this lib on the client side (browser)? Never tried that

roestigraben commented 1 year ago

Hey, you baptised the package client, hence I assumed it would be for this purpose.

Maybe I had to hack a few things, I don't remember.

Anyway, for any help on the CORS issue, I would be happy to see a solution.

I tried on a pretty empty test with only the URL construct and the headers feeding into a fetch, but to no success. I read everywhere that I would need to add something to the server side on which evidentely I don't have access

BTW I also fetch some wind data from an API from Meteomatics and I face similar issues.

fetimo commented 1 year ago

Hi @roestigraben, I highly recommend using this package as part of your back-end. Using it in the browser will expose your security token and bring up CORS issues, like you found. This article explains more on CORS and what it means.