Iframe and CORS for embedded PLC HTTP server

After learning that it’s possible to show an HTTP server in a component I began digging into how to get it to work.

I’m able to dynamically determine the path required to launch using code similar to this

const client = this.context.createResourceDataClient();
    
    // Queries the "active device" on this page to find its HTTP server
    client.query({
      selector: 'Agent',
      fields: ['servers.publicId', 'servers.type']
    }, result => {
      this.server = result[0].data.servers.find(server => server.type === 'http');
    });

However, when I try to use this source in an iframe, it simply opens and redirects in a new tab.
I believe to properly allow an iframe to show a ‘webpage’ from another domain would require changing the CORS policy?

Can this be done via my portal settings?

1 Like

Turns out that something had locked out the HTTP server on my device, after a reboot my component magically worked.

So I can confirm that using an iframe, and this logic above to set the iframe src works.

1 Like