Problem
When initializing @interopio/browser in a Browser Client application, you may encounter the following error if the app is opened directly in the browser rather than through an io.Connect Main app via this.store.getInitError():
Error: Cannot initiate glue, because this window was not opened or created by a glue client
Cause
This error occurs when a Browser Client app is opened directly in the browser (e.g., by navigating to its URL manually) instead of being opened by an io.Connect Main app (Browser Platform).
In io.Connect Browser, all Browser Client apps that use the @interopio/browser library must be started from a Main app that uses the @interopio/browser-platform library. The Main app is responsible for configuring the entire io.Connect environment and acts as a central hub for all Browser Client apps. If a Browser Client app is opened independently, outside of this environment, the connection to io.Connect cannot be established, resulting in the error above.
Correct path
-
Set up a Main app using the
@interopio/browser-platformlibrary. This app will serve as the entry point for your io.Connect Browser project. -
Open your Browser Client app through the Main app - for example, using
glue.appManager.open(), rather than navigating to it directly in the browser.
After that, @interopio/browser should initialize correctly.
- An io.Connect Browser project must have a Main app (Browser Platform). It is the entry point for end users.
- A Browser Client app cannot configure the io.Connect environment on its own, it expects the Main app to have already done so.
- If the Main app is closed, all Browser Client apps lose their connection to io.Connect.