adobe / adobe/aio-cli-plugin-console

this plugin does not use the proxy set via the env vars HTTP_PROXY, HTTPS_PROXY

Aperta
#218 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
JavaScript
Stelle
8
Fork
11
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Expected Behaviour

Console commands use the proxy set via the environment variables `HTTP_PROXY` and/or `HTTPS_PROXY`.

## Actual Behaviour

Console commands do not use the proxy set via the environment variables `HTTP_PROXY` and/or `HTTPS_PROXY`.

## Reproduce Scenario (including but not limited to)

1. Run a proxy locally, use the proxy code at [mitmproxy.org](https://mitmproxy.org).
2. For your App Builder project, set the env vars `HTTP_PROXY` and `HTTPS_PROXY` to `http://127.0.0.1:8080` and `https://127.0.0.1:8080` respectively
3. Verify that the proxy settings are set via running `aio info`
4. Run `aio console org list` - it should hit the proxy, but it does not (see logs in the Terminal)

## Investigation

The library that we use [@adobe/aio-lib-console](https://github.com/adobe/aio-lib-console), uses the[ `swagger-client` npm library](https://www.npmjs.com/package/swagger-client?activeTab=readme), which uses the default `fetch` capability in node.js >=18. Node does not respect the `HTTP_PROXY` and `HTTPS_PROXY` environment variables, it has to be handled in the client library itself, and the library does not do it directly.

## Proposed Fix

The swagger-client library has a capability to [set your own fetch implementation](https://github.com/swagger-api/swagger-js/blob/6957fe1d45d2df886f5011018e89ce3a04f12be6/docs/usage/http-client.md#custom-fetch) via a `userFetch` property - we could use the[ proxied fetch](https://github.com/adobe/aio-lib-core-networking?tab=readme-ov-file#ProxyFetch) implementation in [@adobe/aio-lib-core-networking](https://github.com/adobe/aio-lib-core-networking) in aio-lib-console.

## Workaround

There is no true workaround since node.js does not use system proxy settings (so you can't set it there).
The only way for the command to work is to not use the proxy.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con l’integrazione del comando della console usando @adobe/aio-lib-console e verifica come swagger-client è configurato per le richieste. Leggi la documentazione di userFetch di swagger-client e l’implementazione di ProxyFetch in @adobe/aio-lib-core-networking. Il lavoro è completato quando aio console org list rispetta HTTP_PROXY e HTTPS_PROXY quando queste variabili sono impostate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, nodejs
Ambito
cli, networking
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.