I live in a restricted country & Services like Firebase need VPN to be used. so I'm creating the flutter application which uses Firebase as a backend & i want to know can i set Proxy to whole of the connections in app to GET & POST, etc. requests ?
I live in a restricted country & Services like Firebase need VPN to be used. so I'm creating the flutter application which uses Firebase as a backend & i want to know can i set Proxy to whole of the connections in app to GET & POST, etc. requests ?
You haven't said for what platform, but at least for Unix-like things, most applications and libraries respect the http_proxy environment variable, which you can set in most shells like:
$ export http_proxy=http://server-ip:port/
$ export http_proxy=http://127.0.0.1:3128/
$ export http_proxy=http://proxy-server.mycorp.com:3128/
$ export http_proxy=http://foo:bar@server-ip:port/
$ export http_proxy=http://foo:bar@127.0.0.1:3128/
$ export http_proxy=http://USERNAME:PASSWORD@proxy-server.mycorp.com:3128/
The proper string will be specific to your environment. Details on interpretation of the environment variables are at: https://api.flutter.dev/flutter/dart-io/HttpClient/findProxyFromEnvironment.html.
http_proxy=http://server_ip:port https_proxy=http://server_ip:port
pub_specs.yaml
http_proxy: ^1.1.0
main.dart
import 'package:http_proxy/http_proxy.dart'; import 'package:flutter/foundation.dart'; ... void main() async { ... WidgetsFlutterBinding.ensureInitialized(); HttpProxy httpProxy = await HttpProxy.createHttpProxy(); httpProxy.host = "server_ip";// replace with your server ip httpProxy.port = "port";// replace with your server port HttpOverrides.global=httpProxy; ...