I can`t connect from Node-RED to Freeboard.io using JSON - json

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?

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:
Use sitelock on your host and add Access-Control-Allow-Origin to you response headers.
Use a https proxy and a browser extension to allow cross access.
bye!

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/

Related

Getting the URL for a bucket or an object using oci-java-sdk

I have already a code to retrieve the objects in the bucket using oci-java-sdk and this is working as expected. I would like to retrieve the URL of the file which was uploaded to the bucket in object storage and when I use this URL, this should redirect to the actual location without asking any credentials.
I saw preauthenticated requests but again i need to create one more request. I dont want to send one more request and want to get URL in the existing GetObjectResponse.
Any suggestions>
Thanks,
js
The URL of an object is not returned from the API but can be built using information you know (See Update Below!). The pattern is:
https://{api_endpoint}/n/{namespace_name}/b/{bucket_name}/o/{object_name}
Accessing that URL will (generally, see below) require authentication. Our authentication mechanism is described at:
https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/signingrequests.htm
Authentication is NOT required if you configure the bucket as a Public Bucket.
https://docs.cloud.oracle.com/en-us/iaas/Content/Object/Tasks/managingbuckets.htm?TocPath=Services%7CObject%20Storage%7C_____2#publicbuckets
As you mentioned, Pre-authenticated Requests (PARs) are an option. They are generally used in this situation, and they work well.
https://docs.cloud.oracle.com/en-us/iaas/Content/Object/Tasks/usingpreauthenticatedrequests.htm
Strictly speaking, it is also possible to use our Amazon S3 Compatible API...
https://docs.cloud.oracle.com/en-us/iaas/Content/Object/Tasks/s3compatibleapi.htm
...and S3's presigned URLs to generate (without involving the API) a URL that will work without additional authentication.
https://docs.aws.amazon.com/AmazonS3/latest/dev/ShareObjectPreSignedURL.html
Update: A teammate pointed out that the OCI SDK for Java now includes a getEndpoint method that can be used to get the hostname needed when querying the Object Storage API. https://docs.cloud.oracle.com/en-us/iaas/tools/java/1.25.3/com/oracle/bmc/objectstorage/ObjectStorage.html#getEndpoint--

How to fix axios.post without using package.json's proxy

The axios.post request doesn't work without proxy.
I am new in react js and using create-react-app
When I use proxy attribute in package.json and give it my http://url:port in my axios.post I start from /api/...
I do not need any config like headers or allow access. And I don't need to stringy data.
My back-end is java using Apache Tomcat and in back-end I have CORS filter that only allows application/json
requests. When I use postman if the header doesn't match , Apache refuses the request by 415 unsupported media type.
The problem begins from where I want to use npm run build. so there is no package.json and I should bring my full url to axios.post's url part : http://url:prot/api/..
Then I removed the proxy part from package.json
Since that I haven't seen any response from java or even it doesn't refuse the request in http monitoring or Apache Log part (in Netbeans)
I did two small things and something changed!
1-Adding JSON.stringfy before data
2-Adding headers Content-Type:Application/json
Now the request is observable in Netbeans (the back-end) BUT the messege is unsupported media type although i have added to axios.post's config(and itself caused the request received )!!!
there is some thing else : when I use the fire fox CORS enable adds on every things goes grate but only with that...
This is my first project. please explain like I'm 5! I do not know anything more!
Or if someone has any better way; is there any way i can use axios.post without package json proxy?

Crate DB with Nginx Binding

I was wondering is there a way to bind Nginx web server with CrateDB Backend to receive JSON data over https and store them in the CrateDB.So basically CrateDB should run as an appserver with nginx binding. The longer route would be to use php or python code to do this, but if there is an easier option available to do this it would be great. If any of you have been able to do this please let me know.The direct HTTP binding via REST API is a no go as it does not support HTTPS at this point in time. let me know your thoughts!
putting nginx as proxy in front of crate (and write an application in lua) is straight forward: https://crate.io/a/readonly-crate-with-nginx-and-lua/

cordova cross domain request

I want to create a cordova generic client for debug purpose. but I face the cross domain request problem. My case is:
1. I deploy my source code (html code) on a web server A.
2. My backend data source is from server B.
3. I create a cordova app and run on the device or simulator. the App access the url from server A and open the app page, that work fine. but when my js code read data from Server B, all request is failed. I guess it's cause by cross domain restriction.
Any one have solution to resolve this problem?
Thanks!
Well, since your initial HTTP request goes through and HTML is returned, it seems that the connection from the Cordova is working, at least for server A.
What you could try is to upload temporarily "content" to server A which you try to fetch with AJAX calls.
If that succeeds, you can be sure that the fault is on server B and CORS works okay from front-end. In which case you could try to access the A & B from web client etc. to see possible differences in response headers. The server B is in that case probably missing Access-Control-Allow-Origin: * header. Try to add it to your server configuration or try JSONP. Also as a long shot, read your config.xml if you have only allowed connections to server A with
<access origin="<server A>"/>
in which case you obviously need to allow server B too.
If that fails, there is much less to work with and I can only suggest you to study resources like enable-cors.org which demonstrate how to actually allow CORS.

How to make REST Request to Baasbox server using POSTMAN extension?

I just installed Baasbox on my laptop and everything are work well. But when I try to make a request to create a new user, or anothe REST request using POSTMAN extension, I always got "Invalid Json" error. Is there any mistakes with my request?
it seems that you want to create a user.
In this case you have to set parameters like in the image below.
In particular you have to set "raw" instead of form-data, and also you do not need to set the Authorization header when signing up.
Further info here: BaasBox Signup API