http icon indicating copy to clipboard operation
http copied to clipboard

http.get and http.head methods changing https request to http request in FlutterWeb PWA for urls from its own domain

Open P5music opened this issue 4 months ago • 0 comments

I created a PWA with Flutter Web. When I use the http.get or http.head functions with an url like http://www.myapp.info/api/validate/?url=https://external.site.com/path/file.ext but it likes it if the url has a fake file (I need a different .htaccess rule for that) http://www.myapp.info/api/validate/fake_file.ext?url=https://external.site.com/path/file.ext this is a workaround.

In the former case the request gets changed into something starting with http://www.myapp.info/.... and in the browser I get an error like

Mixed Content: The page at 'https://www.myapp.info/appdev/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.myapp.info/api/validate/?url=.....'. This request has been blocked; the content must be served over HTTPS. ClientException: XMLHttpRequest error., uri=[https://www.myapp.info/api/validate?url=

It is ascertained that the request does not even leave the browser, Chrome or Firefox (Firefox calls it Active Mixed Content)

My PWA is not working because of this, for a certain feature, unless I use the workaround and change also the htaccess rule on my server.

No matter how I create the uri request, even with https method itself, it gets changed. The same using the dio package (using that, the error says that the network layer is the cause)

P5music avatar Oct 09 '24 13:10 P5music