cordova-plugin-inappbrowser
cordova-plugin-inappbrowser copied to clipboard
[Android] beforeload event for POST method is not fired
Bug Report
beforeload event for POST method is not fired
Problem
I read this https://github.com/apache/cordova-plugin-inappbrowser/pull/367
And try to build an app with https://github.com/dpa99c/cordova-plugin-inappbrowser-test
Then open inappbrowser with beforeload = YES option.
Click on GET link
, beforeload, loadstart and loadstop events are fired
Click on Submit
, only loadstart and loadstop events are fired
What is expected to happen?
beforeload
event should be fired with Submit form (POST method)
What does actually happen?
Click on Submit
, only loadstart and loadstop are fired
Information
Android: 7.1 Cordova ver 9 source code and package.json get from https://github.com/dpa99c/cordova-plugin-inappbrowser-test
Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
As far as I can see in the code, there were preparations to get POST
supported, but it is not yet handled. The PR you mention paves the way a bit, and makes sure that POST
doesn't break too much (before it would not consider the request method).
if beforeload=yes is specified and a POST request is detected as the HTTP request method, beforeload behaviour will not be applied
That is visible in the current code.
The README currently mentions:
Note that POST requests are not currently supported and will be ignored (if you set beforeload=post it will raise an error).
This could be improved to read something like:
Note that POST requests are not currently supported and will be ignored (if you set beforeload=post it will raise an error, if you set beforeload=yes it will only handle GET requests).
Is there any workaround? I encounter the same issue.
@pptrexvn @caominhvu Any one found workaround for this? @wvengen Any information on when the support for POST get's released?
Below is my workaround, but it is on backend side:
-
To have another GET method to do whatever you want with the POST originally (move all logics from POST to the new GET api)
-
For the original POST api, just return a status code: 301 (redirect) + link to the GET method
So, when client side calls the POST method, backend side will redirect to the GET method and return the result of GET method. As a result, beforeload will be triggered since from client side, it is a GET now.
Hope this helps
@caominhvu Thanks for your reply. In our scenario sending data in url will lead to security issue.
@mdivya-symplr there is no data sending in URL, all data sent from client side should be in the POST method, not in the GET, the redirect is executed automatically by browsers or inapp browsers. There is no code change in your client side
okay. Thank You @caominhvu
https://github.com/apache/cordova-plugin-inappbrowser/pull/755