09-07-2017 9:53 PM - edited 02-04-2024 12:52 AM
Hey folks,
Just leveraging a lightweight HTML5 (bootstrap + JQuery) page that will show output data from an arduino device I hooked up.
The page itself will be hosted on cloud platform, but an issue I'm running into right now while previewing the page on my desktop and from the WebIDE is that CORS is not enabled specifically I'm getting the error "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.".
How do I get around this?
I figured it out, and I won't let this be one of those phantom posts online where OP doesn't post his resolution.
To get around CORS, one must first leverage destinations in cloud platform. The github has some destinations you can upload and the steps for configuring it are here.
Now, to leverage the destination in this case you have to create a file called neo-app.json in the root of your project, at which point you can populate it with the destinations you have just created
{
"routes": [
{
"path": "/iotmms",
"target": {
"type": "destination",
"name": "iotmms"
},
"description": "MMS Destination"
},
{
"path": "/iotrdms",
"target": {
"type": "destination",
"name": "iotrdms"
},
"description": "RDMS Destination"
}
]
}
and then to leverage that from within javascript you can simply just refer to the url
var url = "/iotmms/v1/api/http/app.svc/[odataquery]";
That's it!
Cheers,
Jath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jathavan,
you would need to leverage HTTP Destinations [1]. Please, refer to the IoT StarterKit UI5 consumption examples [2] or [3], if you would like to see it working end-to-end.
Regards,
Anton
P.S. Please, also familiarize yourself with the Community Rules of Engagements [4] and especially with #3 - search before you post. CORS question was asked multiple times already in different contexts.
[2] https://github.com/SAP/iot-starterkit/tree/master/neo/apps/ui5/consumption
[3] https://github.com/SAP/iot-starterkit/tree/master/neo/apps/ui5/consumption-advanced
[4] https://www.sap.com/community/about/rules-of-engagement.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.