I can`t connect from Node-RED to Freeboard.io usin

2019-06-13 00:08发布

问题:

I trying to create a freeboard dashboard. I have a Arduino with four sensors that send their informations by mqtt. So, I on Node-RED I gen a JSON to response get request in /saida.

[{"id":"3f699b5.c91f064","type":"http response","z":"c7d4e8c8.509218","name":"","x":1184,"y":589,"wires":[]},{"id":"a3ed6250.1d64","type":"json","z":"c7d4e8c8.509218","name":"","x":1120.5,"y":540,"wires":[["3f699b5.c91f064"]]},{"id":"971f41c1.a1265","type":"function","z":"c7d4e8c8.509218","name":"","func":"msg.payload = {\"temperatura\":\"25\"}\nreturn msg;","outputs":1,"noerr":0,"x":1015.5,"y":584,"wires":[["a3ed6250.1d64"]]},{"id":"ed9f7a2a.604728","type":"http in","z":"c7d4e8c8.509218","name":"http in","url":"/saida","method":"get","swaggerDoc":"","x":850,"y":582,"wires":[["5b40d38c.5cc7ec","971f41c1.a1265"]]}]

In this moment, I`m using a static JSON to make a test. I have a use the host like:

my-public-host:1880/saida -> {"temperatura":"25"}

I access it by a proxy, the JSON returns ok. On ping.eu port check, the port is open. I ensure that my host is public.

But on my freeboard, I add it as datasource, then it says "never" update and I can`t read the JSON info.

What I should do to solve it?

回答1:

I solved my problem.

There is a bug in freeboard.io. the thingproxy.freeboard.io don't work. The the browser don't let the freeboard.io make AJAX request for other link that isn't https. Besides, the browser don't let make a AJAX request for an other host.

There is two solutions:

  1. Use sitelock on your host and add Access-Control-Allow-Origin to you response headers.
  2. Use a https proxy and a browser extension to allow cross access.

bye!



回答2:

Correct.

If the data source is flask based app, you can follow this link below to make freeboard read.

https://flask-cors.readthedocs.io/en/latest/