As many people know, Chrome (and other browser based on Chromium, at least Brave and Edge) still rely on the desktop’s proxy settings on Linux (I remember writing about this back in 2011).

Under normal circumstances, it is as easy as running the program with --proxy-pac-url commandline switch, like so:

$ brave --proxy-pac-url="https://example.com/proxy.pac"

But what if you want to use a local file?

At some point (around Chrome 77 it seems), Chrome stopped accepting file:// URLs for --proxy-pac-url.

The fix:

brave --proxy-pac-url='data:application/x-javascript-config;base64,'$(base64 -w0 /path/to/proxy.pac)

This will encode the file with base64 and load it as if it is a web respsonse.

A simple script to launch the browser (Brave in this case) with the correct paramters:

#!/bin/bash

/usr/lib/brave-bin/brave --profile-directory=Default --proxy-pac-url='data:application/x-javascript-config;base64,'$(base64 -w0 $HOME/etc/proxy.pac) "$@"