Read the statement by Michael Teeuw here.
missing 'Access-Control-Allow-Origin'
-
This comes up quite often, not just here on the MM² forums, but out in the wild too:
http://lmgtfy.com/?q=Access-Control-Allow-Origin
Basically the answer is: you can’t do that … cross-domain … security … find proper API … all of the above …
-
@KirAsh4 Well, not strictly true ;) https://forum.magicmirror.builders/topic/157/mmm-opentherm
But yes, you’ll need to fix the source! -
Just use a
node_helper.js
to get around the access-allow-origin policy. -
After googleing 1000 different websites I’ve used the
nood_helper.js
solution.And to load the nood_helper.js I had to restart electron.
pm2 restart mm
that coast me another hour to find out why it was no loading :-):gun: :hammer: -
I am facing the same problem. Could you please give an example, how you used node_helper.js to circumvent the access-allow-origin policy?
Thanks!
-
Like here for example:
https://github.com/yawnsde/MMM-RNVYou use request instead.
-
Thank you!
And why does it have to be in node_helper, not in the main script? Sorry, if this question sounds stupid, I’m new to developing modules.
Also, is there a reason for declaring var self = this; and using self.func instead of this.func? I have seen this quite a bit and couldn’t understand why people do this…
-
@KrawallKurt
Please note I am not an experienced javascript developer either. When using addon modules/libraries likerequest
you use thenode_helper.js
to load this library. I am not sure if it is not possible at all to do so in the main module file or if it is just complicated. Maybe @strawberry-3-141 can clarify :)self = this
was used in other modules and I added it to my module as well, because I did not want to possibly break something by leaving it out. There is a lot of discussion on the web why this is used and if this still should be used. -
Concerning the self=this question, I found a neat article giving som explanations: https://alistapart.com/article/getoutbindingsituations
The other question: Could it be, that node_helper is executed on the server and the main script is executed on the client?