Execute Command At API Call Execution

My question: Is it possible to execute a command at the time you click ‘Send’?

Details (like screenshots):

I have a number of API calls that I typically use curl for - they require pre-pending the curl with a binary and action.

For example:

cloudflared access curl https://my-api-server/api/endpoint

The requirement stems from using a Cloudflare zero-trust/remote access solution called Cloudflare Access to connect to a host via the command line without specifying a global proxy within the operating system (which also isn’t possible) - the binary is known as cloudflared (or Cloudflare Tunnel).

Per Cloudflare’s documentation:

Cloudflare’s cloudflared command-line tool allows you to interact with endpoints protected by Cloudflare Access. You can use cloudflared to interact with a protected application’s API.

While this option is technically forcing an authenticated proxy, it’s not implemented as a traditional proxy would be - it’s not possible to just specify a proxy URL and port (i.e. https://myproxy.company.com:8080) in this particular case.

More details are available here → Cloudflare Zero Trust - Authenticate a Session from the Command Line

Also - when running ‘cloudflared access’ the first time, the user is redirected to a web page that will issue a challenge for credentials or request the user authorize the session at which point cloudflared generates an authentication token that is used for future requests until the token expires.

This would be similar in nature to the “Telnet command or local proxy” option found in PuTTY.

I wasn’t able to find any documentation on this. Perhaps I’m missing something?

Thanks in advance!

1 Like

I’m also very interested to get some pointers as to how to achieve this. Thank you in advance!