Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


How can I from a page on a publicserver access a Home Center 3 on a local network


Recommended Posts

I need help or clarification.
My situation is the following.
I have a website on our public server.


When you open it, information must be retrieved from the Home Center 3 on the local network, which must be used on the page.

 

This is of course a problem, as the security of Chrome and other browsers does not allow accessing local resources when called from a web page on a public page.

Is there any way this can be done or do I have to find a completely different solution

 

 

This is html-page on the server

 

<!doctype html>
<html lang="en">
<head>
  <style> </style>
  <script src="https://code.jquery.com/jquery-3.6.3.js"></script>
  <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
  <script>
    let params = (new URL(document.location)).searchParams;
    var HC3ip = params.get('ip');
    var HC3data = params.get('data');
    var HC3sn = "HC3-00000000";
    var user = "[email protected]";
    var code = "password";

    console.log("Params ip:" + HC3ip + ", data:" + HC3data + ", sn:" + HC3sn);
    
    function HC3_get(_url, success )  {
      console.log("HC3_get: url:" + _url);
      fetch(_url, {
         method: 'GET',
        headers: {
            'Content-Type': 'application/json',
              'accept': 'application/json',
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Methods': "GET, OPTIONS, POST, PUT,PATCH,OPTIONS",
            'Access-Control-Allow-Credentials':'true',
            'Access-Control-Allow-Headers':'Authorization,Content-Type,accept, *',
            'Access-Control-Allow-Private-Network':'true',
            'authorization': 'Basic ' + HC3data
          }
      })
           .then(response => response.json())
           .then( json => success(json))
           .catch( err => console.log(err));
    }
    
    function makeInfo()  {
          $("#address").html(graphic_Info.address + ", " + graphic_Info.sn);
    }
    
    
    HC3_get( "https://" + HC3ip + "/api/globalVariables/graphic_Info", 
            function(json) 
            {
                console.log("HC3_get(Info): " + JSON.stringify(json));
                graphic_Info = json;
                makeInfo(); 
            })
  </script>
  
  
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Logic Group/title>
</head>
 
<body>
  <h2 id="address"></h2>
</body>
</html>

 

The response is

 

Params ip:192.168.10.153, data:xxxxxxFhcmRzdmVqM0Bnxxxxxx5jb206SmFjb2IyMDAxIQ==, sn:HC3-00000000
Floorplan2.htm?ip=192.168.10.153&data=xxxxxxFhcmRzdmVqM0Bnxxxxxx5jb206SmFjb2IyMDAxIQ==:19   HC3_get: url:https://192.168.10.153/api/globalVariables/graphic_Info
Floorplan2.htm?ip=192.168.10.153&data=xxxxxxFhcmRzdmVqM0Bnxxxxxx5jb206SmFjb2IyMDAxIQ==:20          GET https://192.168.10.153/api/globalVariables/graphic_Info net::ERR_CERT_AUTHORITY_INVALID
HC3_get @ Floorplan2.htm?ip=192.168.10.153&data=xxxxxxFhcmRzdmVqM0Bnxxxxxx5jb206SmFjb2IyMDAxIQ==:20
(anonymous) @ Floorplan2.htm?ip=192.168.10.153&data=xxxxxxFhcmRzdmVqM0Bnxxxxxx5jb206SmFjb2IyMDAxIQ==:44
Floorplan2.htm?ip=192.168.10.153&data=xxxxxxFhcmRzdmVqM0Bnxxxxxx5jb206SmFjb2IyMDAxIQ==:35 TypeError: Failed to fetch
    at HC3_get (Floorplan2.htm?ip=192.168.10.153&data=xxxxxxFhcmRzdmVqM0Bnxxxxxx5jb206SmFjb2IyMDAxIQ==:20:7)
    at Floorplan2.htm?ip=192.168.10.153&data=xxxxxxFhcmRzdmVqM0Bnxxxxxx5jb206SmFjb2IyMDAxIQ==:44:5

 

 

 

Link to comment
Share on other sites

@[email protected]

And how are you really asking HC3 from a public server?
I assume that you have a server with one interface to the net and the other to the internal network for communication with HC3.
It would also like to separate part of the html query - transfer it to PHP like any other interpreter, translate the queried values from HC3 into other variables, so that nothing from the prime communication between HC3 and the server can reach the end user.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...