apache / apache/cordova-plugin-inappbrowser

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

Open
#1,064 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

# 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](https://github.com/user-attachments/assets/3d28b24c-1363-40f1-a052-cae4cb87c81f)
(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)](https://github.com/user-attachments/assets/d8fe32c3-f014-4179-b843-952b00e88309)

### 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

- [x] 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)**
- [x] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the 302 redirect with the beforeload callback and compare the iOS handling of beforeload with the reported loaderror event. Trace the plugin's iOS event entry points for callback(params.url), redirects, and loaderror; done means the redirected URL loads without the Frame Load Interrupted error while preserving the existing PDF behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, javascript, objective-c
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.