3

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:

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

enter image description here

1
  • Did you find any solution to that? We are having a very similar problem running react native web app wrapped in expo... Commented Mar 7, 2023 at 23:45

1 Answer 1

1

As I mentioned in the comment above, we had a very similar issue, except we are are running react native web app wrapped in expo.

The short answer is, make sure you set up the right "referrer policy" for your application.

A bit longer answer:

Our third party widget worked everywhere except our dev environment. After days of debugging I realized that somehow our referrer policy is overwritten in our dev env (Azure setup).

Modern browsers set the referrer policy to "strict-origin-when-cross-origin", which sets document.referrer to your origin url.

We had our set to "same-origin" in one of our environments and this header doesn't share its origin with the cross origin destination, therefore, when the third party widget tried to postMessage back to us, we would get nothing, because document.referrer was empty.

Here's more info on Referrer Policy

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.