You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
(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:
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);
});
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:
(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:
Command or Code
Environment, Platform, Device
Version information
Cordova: Cordova 11, cordova-ios@6, cordova-plugin-inappbrowser v6
Checklist
The text was updated successfully, but these errors were encountered: