Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load URL: Frame Load Interrupted being thrown on URL with a 302 redirect #1064

Open
2 of 3 tasks
dylanfpaul opened this issue Aug 1, 2024 · 1 comment
Open
2 of 3 tasks

Comments

@dylanfpaul
Copy link

dylanfpaul commented Aug 1, 2024

Bug Report

Problem

What is expected to happen?

When I am using a beforeload event listener, passing a url to the callback should load that URL as expected.

What does actually happen?

cordova-plugin-inapp browser fails to load the url and instead throws an error:
image
(URL blacked out)

Information

What is significant here is that this request is a 302 redirect. I believe that this may be the catalyst for why this error is popping up but I am not sure if inapp-browser's event listener just straight up can't handle "redirect" urls, or if I am doing something wrong.

Here is some info on the requested URL when it is made successfully (without the beforeload handler and without the error being thrown, notice how it is has a status of "302 Found"). How this works is that the "Request URL" is the original URL being requested, and the "Location" response header is the new URL that the client should be redirected too:
image (1)

Command or Code


let inAppBrowserRef = window.open(url, '_blank', 'location=no,hidden=yes,toolbar=yes,enableViewportScale=yes,shouldPauseOnSuspend=yes,allowInlineMediaPlayback=yes,usewkwebview=yes');

inAppBrowserRef.hidden = true;

inAppBrowserRef.addEventListener('beforeload', (params, callback) => {
                  if(params.url.match(".pdf")){
                     console.log('MATCH PDF');
                     window.open(params.url, '_system');
                  } else {
                     console.log('DEFAULT HANDLING');
                     // THIS IS WHERE THE ERROR OCCURS
                     callback(params.url);
                   }
});

...

inAppBrowserRef.addEventListener('loaderror', (event) => {
                  const msg = `[${event.code}] Cannot open URL: [${event.url}].  Message from the server is: ${event.message}`;

                  inAppBrowserRef.close();
                  inAppBrowserRef = undefined;

                  handleLoadError(dispatch, msg);
});

Environment, Platform, Device

  • MacBook Pro Sonoma 14.4.1
  • Xcode 15.3 iPhone 15 Pro Simulator

Version information

Cordova: Cordova 11, cordova-ios@6, cordova-plugin-inappbrowser v6

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version (not possible due to quirks with Node and other unmaintained plugins)
  • I included all the necessary information above
@mariyasb
Copy link

Hi @dylanfpaul! Did you manage to find a workaround for this? I'm facing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants