[Ethereum] How to use HardHat behind a proxy

hardhat

I'm using HardHat (repo) behind a firewall, requiring outbound connections to use a proxy. This is usually pretty easy, for example to configure NPM for using proxy, you can set environment variables HTTP_PROXY and HTTPS_PROXY.

In HardHat, when running commands like npx hardhat compile, HardHat reaches out to https://solc-bin.ethereum.org/windows-amd64/list.json to get the latest version list of the solidity compiler solc. The command fails because it cannot reach out to that address, making the fetch fail and subsequently the command fail. (Error message is below with Stack Trace)

Is there…

A) Configure HardHat to work with a proxy?

or

B) Manually install solc (with something like yarn add solc and update hardhat.config.js) and disable HardHat from checking for a list of compilers and installing a compiler?

Error:

HardhatError: HH502: Couldn't download compiler versions list. Please check your connection.
    at CompilerDownloader.downloadCompilersList (C:\Projects\myProject\node_modules\hardhat\src\internal\solidity\compiler\downloader.ts:185:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

    Caused by: FetchError: request to https://solc-bin.ethereum.org/windows-amd64/list.json failed, reason: read ECONNRESET
        at ClientRequest.<anonymous> (C:\Projects\myProject\node_modules\node-fetch\lib\index.js:1461:11)
        at ClientRequest.emit (events.js:315:20)
        at TLSSocket.socketErrorListener (_http_client.js:426:9)
        at TLSSocket.emit (events.js:315:20)
        at emitErrorNT (internal/streams/destroy.js:92:8)
        at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
        at processTicksAndRejections (internal/process/task_queues.js:84:21)

Edit/Update:

I found the task name subtask(TASK_COMPILE_SOLIDITY_RUN_SOLCJS)
to compile using solcjs. Is there a way to configure solcjs as the default compiler? Possibly through an ENV variable?

Update May 2021:

Best Answer

They are trying to resolve this issue.

https://github.com/nomiclabs/hardhat/pull/1291