Skip to content

Extension proxy support #12588

Open
Open

Description

@CodeZombieCH

Proxy support for Visual Studio Code has been introduced recently through environment variables/settings (see https://code.visualstudio.com/docs/setup/setup-overview#_proxy-server-support). As an extension developer I would like to use these settings when requesting resources from the internet. My current implementation fails for users using a proxy.

What is the recommended way for an extension to use a proxy?

I could not find a vscode API that exposes methods to make requests using a proxy other than access to the proxy settings (workspace.getConfiguration()) and implementing everything on my own. Looking at the Visual Studio Code code base I identified the code that adds support for proxies, but copy&paste it into my extension would result in duplicated and potentially outdated code, which is something I want to avoid whenever possible. As I am probably not the only extension developer accessing the internet, I would like to hear your opinion on this issue. Any feedback would be greatly appreciated.

Activity

  1. jrieken commented on Sep 28, 2016

    @jrieken
    Contributor

    -1 for adding this for to the API but +1 for extracting our code into a node-module. João Moreno (@joaomoreno) how feasible is that? how much code do we add on top of other node-modules?

  2. joaomoreno commented on Sep 28, 2016

    @joaomoreno
    Contributor

    It's thin.

  3. changed the title [-]Expose an API for extensions to use a proxy[/-] [+]Make proxy code reusable[/+] on Sep 28, 2016
  4. jrieken commented on Sep 28, 2016

    @jrieken
    Contributor

    I leaving it with you then ;-)

  5. CodeZombieCH commented on Sep 28, 2016

    @CodeZombieCH
    Author

    A node package sounds like a cool solution. Let me know when it's ready so I can test it and provide feedback.

  6. joaomoreno commented on Apr 26, 2017

    @joaomoreno
    Contributor

    We're going with a different proxy solution in the future, skipping this.

  7. CodeZombieCH commented on Apr 26, 2017

    @CodeZombieCH
    Author

    Do you have any details about that future solution?

  8. 61 remaining items

  9. chrmarti commented on Feb 5, 2025

    @chrmarti
    Collaborator

    Brian Ingles (@bmingles) We discovered that Chromium's fetch (or what Electron surfaces) is not feature-identical with Node.js' fetch and so we have moved on to add proxy support to Node.js' fetch. We expect that to offer better compatibility for code written for Node.js' fetch and have enabled it by default in the user settings:

    Image

    Our work for making Chromium/Electron's fetch available can also be enabled in the user settings if you want to give that a try:

    Image
  10. chrmarti commented on Feb 5, 2025

    @chrmarti
    Collaborator

    Also: The patched fetch and https module both support Kerberos and basic auth and load SSL certificates from the OS.

    For remote connections the upcoming VS Code 1.97 (and current VS Code Insiders) adds a remote user setting to control whether or not the remote extensions should use the same proxy configuration as the local extensions.

  11. merlinz01 commented on Feb 5, 2025

    @merlinz01
  12. bmingles commented on Feb 5, 2025

    @bmingles

    @bmingles We discovered that Chromium's fetch (or what Electron surfaces) is not feature-identical with Node.js' fetch and so we have moved on to add proxy support to Node.js' fetch. We expect that to offer better compatibility for code written for Node.js' fetch and have enabled it by default in the user settings:

    Our work for making Chromium/Electron's fetch available can also be enabled in the user settings if you want to give that a try:

    Thanks Christof Marti (@chrmarti),
    We use self-signed certs for some of our servers and are currently setting the NODE_EXTRA_CA_CERTS env variable in the process running VS Code to include our signing CA certs. There are no proxies involved here, it just seems to be what is required to get NodeJS to trust additional certs.

    Any chance these changes will make it possible for extensions to use the OS trust store instead of requiring NODE_EXTRA_CA_CERTS to be set, or does this only apply to proxy scenarios?

  13. chrmarti commented on Feb 6, 2025

    @chrmarti
    Collaborator

    Merlin (@merlinz01) Could you try with Electron Fetch turned off:
    Image

    Brian Ingles (@bmingles) You can add the certificate to the OS trusted root certificates, these should all be picked up. (Restart VS Code after changing the OS trust store.)

  14. merlinz01 commented on Feb 6, 2025

    @merlinz01

    Christof Marti (@chrmarti) I tried turning off the Electron Fetch and restarting VSCode, but it gives the same error.

  15. bmingles commented on Feb 6, 2025

    @bmingles

    Christof Marti (@chrmarti) I still need to do some more testing, but looks like the Http: Electron Fetch works for our scenario.

    1. It now allows http2 connections via fetch in a spot where we were having to implement a custom transport based on node:http2
    2. the NODE_EXTRA_CA_CERTS seems to no longer be needed

    Thanks!!

    Out of curiosity, is Http: Electron Fetch documented somewhere that I missed, or has it just not made it to the docs?

  16. chrmarti commented on Feb 6, 2025

    @chrmarti
    Collaborator

    Merlin (@merlinz01) Could you open a new issue for us to investigate?

    Brian Ingles (@bmingles) It is not documented beyond the settings itself. We have paused our effort to make it ready to become the default because we have found a way to add proxy support to Node.js' fetch and will likely keep that as the default. That also supports OS certificates and you can pass it an Agent from the undici library to enable http2 if required.

  17. SyaifulnizamshamsudinMax123 commented on Aug 8, 2025

    @SyaifulnizamshamsudinMax123

    Proxy support for Visual Studio Code has been introduced recently through environment variables/settings (see https://code.visualstudio.com/docs/setup/setup-overview#_proxy-server-support). As an extension developer I would like to use these settings when requesting resources from the internet. My current implementation fails for users using a proxy.

    What is the recommended way for an extension to use a proxy?

    I could not find a vscode API that exposes methods to make requests using a proxy other than access to the proxy settings (workspace.getConfiguration()) and implementing everything on my own. Looking at the Visual Studio Code code base I identified the code that adds support for proxies, but copy&paste it into my extension would result in duplicated and potentially outdated code, which is something I want to avoid whenever possible. As I am probably not the only extension developer accessing the internet, I would like to hear your opinion on this issue. Any feedback would be greatly appreciated.
    Thanks you.

  18. chrmarti commented on Aug 20, 2025

    @chrmarti
    Collaborator

    Syaifulnizam Shamsudin (@SyaifulnizamshamsudinMax123) Extensions automatically get the proxy support we added. Currently fetch, http and https all have proxy support added and most NPM packages for network requests use one of these. Please open a bug report if that doesn't work for your extension. Thanks.

  19. hjrb commented on Nov 24, 2025

    @hjrb

    This is still not working. I tried setting https_proxy with either a local proxy (PX) or simply using a fixed proxy Url. Not working. I tried setting proxy in settings.json - not working (that seems to not allow a PAC Url - does it?) I tried --proxy-pac-url - not working. It simply can not find any extension when using CLI code --install-extension . The IDs I tried are all correct and work just fine when used inside VS Code instead.

  20. SyaifulnizamshamsudinMax123 commented on Dec 20, 2025

    @SyaifulnizamshamsudinMax123

    Yes true.

  21. macgeneral commented on Feb 26, 2026

    @macgeneral

    I originally created a workaround for this issue about two years ago for my own use (initially as a Python project). I’ve now cleaned it up, made it cross‑platform compatible, and compiled it into a single binary using Nuitka.

    The project is available here:
    👉 https://github.com/macgeneral/uVSCEM

    Main features

    • Cross‑platform support (Linux, Windows, macOS)
    • Distributed as a single standalone binary (also available via PyPI)
    • Downloads and installs VS Code extensions, extension packs, and marketplace signatures
    • Reads extension IDs from your devcontainer.json (or any JSON file containing a devcontainer extension block)
    • Verifies extension signatures using vsce-sign
    • Supports offline bundles (export/import) for air‑gapped machines

    It was originally built to solve my own workflow needs related to this issue (see #12588 and #29910), but I decided to publish it in case it’s useful to others.

    ⚠️ Disclaimer:
    The Windows and macOS binaries (as well as the Python scripts on those platforms) have not been extensively tested there, although they should work. Feedback and testing on those platforms would be very welcome.
    Hope this helps anyone still affected by this issue.

  22. tiennou commented on Apr 17, 2026

    @tiennou

    I'm getting a

    Unable to load schema from 'http://json.schemastore.org/package': Not Found. The requested location could not be found.
    Unable to connect to http://json.schemastore.org/package. Error: connect EBADF 20.42.128.105:80.
    

    in any package.json file I open, and I'm not sure what's going on. I do not have a proxy (this is a residential network). Loading the URL through my browser correctly nets me what looks like a 40Kb schema file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apifeature-requestRequest for new features or functionalityproxyIssues regarding network proxies

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions