postMessage() in iframe fails, because `document.referrer` returns empty string in iOS

I’m having a problem where a vendor’s javascript is throwing an error because document.referrer returns an empty string as a parameter being sent to postMessage().

ionic info

Ionic:

   Ionic CLI                     : 5.4.16 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 6.0.14
   @angular-devkit/build-angular : 12.2.17
   @angular-devkit/schematics    : 12.2.17
   @angular/cli                  : 12.2.17
   @ionic/angular-toolkit        : 4.0.0

Capacitor:

   Capacitor CLI   : 3.4.3
   @capacitor/core : 3.4.3

Utility:

   cordova-res                          : 0.15.4
   native-run (update available: 1.6.0) : 1.5.0

System:

   NodeJS : v14.18.1 (/usr/local/bin/node)
   npm    : 6.14.15
   OS     : macOS Monterey

@mhartington could you help please to figure it out or address thiss to anyone who can help? :pray:

Without a reproducible example, it could be many things so it’s hard to say. Do you have a small GitHub repo that reproduces this error?