0

I have two different AngularJS web-apps deployed locally using wildfly + IIS (www.sitea.ab.company.com) and just wildfly (www.sitea.ab.company.com:8080).

The first one is always executed first and stores data inside localStorage, while the second one is always opened later using the aforementioned data within the localStorage.

I'm trying to access the first web-app localStorage from the second web-app via this cross-domain-local-storage library, and everything works just as expected while developing and using respectively localhost:9000 and localhost:3010.

Alas, as soon as both web-apps get deployed the cross domain local storage mechanism stops working.

More in particular:

  • the 2nd web-app script finds the needed 1st web-app index page
  • the 2nd web-app script asks for specific data (defined and with a proper value) stored in the 1st web-app localStorage
  • BUT the 2nd web-app gets always value: null for that key

I encountered this problem using both Chrome and IE11, and so far I tried SecurityError: Blocked a frame with origin from accessing a cross-origin frame -- this solution by adding X-Frame-Options ALLOW-FROM sitea.ab.company.com:8080 via IIS Configuration Editor for sitea.ab.company.com but nothing changes (even though I restarted both IIS and the browser with a fresh new cache).

Can you help me find what is going wrong and fix it, basing on these pieces of information?

georgeawg
  • 46,994
  • 13
  • 63
  • 85
Gargaroz
  • 309
  • 7
  • 27
  • Access to data stored in the browser such as localStorage and IndexedDB are separated by origin. Each origin gets its own separate storage, and JavaScript in one origin cannot read from or write to the storage belonging to another origin. See [MDN Web Security Guide - Cross-origin data storage access](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#Cross-origin_data_storage_access) – georgeawg May 03 '19 at 00:26
  • Unless you use iframe post message communication just like the [cross-domain-local-storage does](https://github.com/ofirdagan/cross-domain-local-storage), so the actual point is why this mechanism stops working once the web-app gets deployed to IIS? – Gargaroz May 03 '19 at 08:18

1 Answers1

0

It turned out the problem was not within the IIS configuration, but the Wildfly one was meddling with both web-apps and missing the x-frame-option.

Eventually I solved using this solution

Gargaroz
  • 309
  • 7
  • 27