IoT cloud api requests and cors

I try to connect my device with api, the device with which I´m able to turn on and of led in the IoT cloud dashboard. I have used example code from javascript arduino iot npm package.
I used browserify and threw html and bundle.js to my school serverfolder used in website making practises.

I got this error message, and I really need help how to fix the cors thing and also how can I send button events, I mean light the led, and turn the led off commands through this IoT Cloud API?
Docs were really weird only telling about adding devices on a command and other bigger stuff.
Not sending everyday user events.

Uncaught TypeError: Cannot read property 'fn' of undefined
at util.js:55
at bootstrap.min.js:6
at bootstrap.min.js:6
(anonymous) @ util.js:55
(anonymous) @ bootstrap.min.js:6
(anonymous) @ bootstrap.min.js:6

index.html:1 Access to fetch at 'https://login.arduino.cc/oauth/token' from origin 'http://sharewell.fi' has been blocked by CORS policy: 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.
bundle.js:24 Failed getting an access token: RequestError: TypeError: Failed to fetch
getToken @ bundle.js:24
async function (async)
getToken @ bundle.js:20
run @ bundle.js:32
1.@arduino/arduino-iot-client @ bundle.js:42
o @ bundle.js:1
r @ bundle.js:1
(anonymous) @ bundle.js:1
bundle.js:97604 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://login.arduino.cc/oauth/token with MIME type application/json. See Chrome Platform Status for more details.
ClientRequest._onFinish @ bundle.js:97604
(anonymous) @ bundle.js:97525
emitNone @ bundle.js:82948
emit @ bundle.js:83033
finishMaybe @ bundle.js:100240
afterWrite @ bundle.js:100086
Item.run @ bundle.js:92390
drainQueue @ bundle.js:92360
setTimeout (async)
runTimeout @ bundle.js:92278
process.nextTick @ bundle.js:92380
exports.setImmediate @ bundle.js:101097
Request.init @ bundle.js:49865
RP$initInterceptor @ bundle.js:44976
Request @ bundle.js:49469
request @ bundle.js:45347
getToken @ bundle.js:20
run @ bundle.js:32
1.@arduino/arduino-iot-client @ bundle.js:42
o @ bundle.js:1
r @ bundle.js:1
(anonymous) @ bundle.js:1
index.html:1 Access to XMLHttpRequest at 'http://api2.arduino.cc/iot/v2/devices' from origin 'http://sharewell.fi' 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.

Hi,
How to allow cross origin connections from my own website or webapp to IoT cloud api?

I have all the credentials and token but it gives me cors policy error.

Where can I find tutorial to use leds of my mkr1000 from own site? Havent found any.
How is the event sent to api if I want to toggle a light property the same way as in the dashboard?

I have a cloud api with my maker plan and I want to send commands from web application.
I found no docs or tutorials for doing it.
Is it even possible or is the dashboard only way to push button -> light the led.
I tried npm package and sample code but got cors errors. Where to define Cors things and
how to send command for boolean property Light ?

Anyway it works fine from the dasboard at the moment.

CORS protects the url from being included in a page from a different domain.
the included url must return a CORS header to allow the inclusion.
in your case the API should return it, to allow it, but it is out of your control.
is the API official or it is the internal API of Arduino Cloud Web UI?

Hello,

It is the api which is included in the Arduino IoT Cloud web platform.
It is available on maker plan, and the docs are here:
https://www.arduino.cc/reference/en/iot/api/

They dont tell how to connect own UIapp and how to command device using the api.

I tried also this, but nothing really happens. Only cors error comes when I made the example project and
it doent include any data reveiving or led toggling or anything like that.

Hi @sirensimo7. I see you have three separate threads about Arduino IoT Cloud and CORS. They all seem very similar to me, but I'm not knowledgeable on this topic so I could be wrong on that. Are these three distinct questions, or are they all about the same thing, but worded differently? If they are all on the same topic then I'll merge them into a single thread so that we can consolidate all the discussion to one place.

pert:
Hi @sirensimo7. I see you have three separate threads about Arduino IoT Cloud and CORS. They all seem very similar to me, but I'm not knowledgeable on this topic so I could be wrong on that. Are these three distinct questions, or are they all about the same thing, but worded differently? If they are all on the same topic then I'll merge them into a single thread so that we can consolidate all the discussion to one place.

Yes, Im trying to get answers and Didnt exactly know what is the most right category. Sorry for that.

I think the best category is the Create > IoT Cloud Beta forum section. People who are very knowledgeable about the Arduino IoT Cloud monitor this forum section and will be best able to help you. I have moved your thread there.

Possibly related: