allow CORS for variable sharing on two local html pages

Viewed 5

I am building a little web app that has an admin page and a public dashboard running at the same time which need to communicate with each other in only one way (admin -> dashboard) (see the repo). The local file structure is the following :

HTML
 => admin.html
 => dashboard.html

I came across the possibility to open the dashboard with window.open("dashboard.html"), and, from there, access any object from the admin web page with window.opener.any_variable.

However, despite my two windows being local (same port, same file: protocol, same hostname), the window.opener is Restricted on both Chrome and Firefox, probably because of CROS.

Do you know any way to allow my two windows to access each other variables with window.opener.any_variable method ?

So far, I tried a few meta tag in the HEAD :

<meta http-equiv="Content-Security-Policy" content="child-src file: *; connect-src file: *; frame-src file: *; worker-src file: *">
<meta http-equiv="Cross-Origin-Opener-Policy" content="same-origin-allow-popups">
<meta http-equiv="Cross-Origin-Embedder-Policy" content="require-corp">

I always have the backup solution to serialize everything and use the localStorage API, but it is a pain to use because I use custom objects.

0 Answers
Related