D
Deno

help

How to set proxy to overall all requests coming from application?

Bblock_hacks11/5/2023
In Node JS, we can import https and set https.proxy = "proxyDetails However, I couldn't find a way to do so in Deno. I even tried to run node js child_process app with proxy over Deno, still not possible.
DAHDeno AI Helper11/5/2023
In Deno, proxy configuration is read from environmental variables: HTTP_PROXY, HTTPS_PROXY and NO_PROXY. According to the documentation, if these environment variables are not found, Deno falls back to reading proxies from the registry in the case of Windows. Here's how you can set these environment variables: 1. HTTP_PROXY and HTTPS_PROXY: These variables hold the URL of the proxy server. The format is http://<host>:<port> for HTTP_PROXY and https://<host>:<port> for HTTPS_PROXY. 2. NO_PROXY: This variable should contain a comma-separated list of domain extensions proxy should not be used for. Please note that these environment variables need to be set in the environment where the Deno process runs. How to set these variables depends on your operating system and shell. For example, in a Unix-based system with a bash-like shell, you can set these variables as follows:
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=https://proxy.example.com:8080
export NO_PROXY=".example.com,.deno.land"
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=https://proxy.example.com:8080
export NO_PROXY=".example.com,.deno.land"
Then, you can run your Deno program in the same shell session, and it will pick up these proxy settings. Remember, this is a process-level setting and will affect all fetch and module download requests made by the Deno process. If you want to set the proxy for a specific fetch request, you can do so by creating a custom HTTP agent with the proxy settings and passing it in the options of the fetch request. However, this feature is not currently supported in Deno according to the documentation. 🦕
Bblock_hacks11/5/2023
I am using npm:google-trends-api. I am not making any fetch requests myself. How can I set proxy so even my library requests under the hood use proxy to make requests
DAHDeno AI Helper11/5/2023
According to the documentation, Deno reads proxy configuration from environment variables: HTTP_PROXY, HTTPS_PROXY, and NO_PROXY. If these environment variables are not found, Deno falls back to reading proxies from the registry in the case of Windows. So, if the npm:google-trends-api library you are using makes HTTP or HTTPS requests under the hood, these requests should respect the proxy settings defined in these environment variables. Here's how you can set these environment variables: 1. HTTP_PROXY and HTTPS_PROXY: These variables hold the URL of the proxy server. The format is http://<host>:<port> for HTTP_PROXY and https://<host>:<port> for HTTPS_PROXY. 2. NO_PROXY: This variable should contain a comma-separated list of domain extensions proxy should not be used for. Please note that these environment variables need to be set in the environment where the Deno process runs. How to set these variables depends on your operating system and shell. For example, in a Unix-based system with a bash-like shell, you can set these variables as follows:
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=https://proxy.example.com:8080
export NO_PROXY=".example.com,.deno.land"
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=https://proxy.example.com:8080
export NO_PROXY=".example.com,.deno.land"
Then, you can run your Deno program in the same shell session, and it will pick up these proxy settings. Remember, this is a process-level setting and will affect all fetch and module download requests made by the Deno process. If you want to set the proxy for a specific fetch request, you can do so by creating a custom HTTP agent with the proxy settings and passing it in the options of the fetch request. However, this feature is not currently supported in Deno according to the documentation. 🦕
Rraunioroo11/5/2023
does setting proxy config as environment variable somehow not work for you? i think it should exactly make any third party library fetch calls to also use the proxy
Bblock_hacks11/5/2023
doesn't work for me at all tried on Ubuntu, Kali and Windows 11
Rraunioroo11/5/2023
are you sure the env vars are set correctly so that Deno seems them? Does
const env = Deno.env.toObject();
console.log("env:", env);
const env = Deno.env.toObject();
console.log("env:", env);
print them out? If yes, then idk what the issue could be
Bblock_hacks11/5/2023
I did explicitly printed them out as I mentioned, did it on Linux & Windows

Looking for more? Join the community!

Recommended Posts
Overload not typing object literalsshouldn’t only “real” show up as a property here? if not, how could I achieve that?Making Post Request To HubSpot ApiHi there I'm trying to make a post request to the HubSpot Api. However the request results in a "HubCLI prompt consistent with Deno CLII want to make outputs of my CLI tools look consistent with Deno CLI. Is there a rust crate to do thcannot set property on fetch responsein the browser this works ```javascript let o = await fetch('https://deno.com'); o.asdf = 2 console.Component testing with DenoI've run through a zillion possible setups with Deno and I'm still struggling to understand exactly Is there any way to run deno as a cluster on one machine? (like pm2)I plan to service with deno, but PM2 does NOT support deno. Is there any way to run deno as a clusthow to set remoteAddr from http header Forwarded for or X-Forwarded forIn some environments are the TCP Client IP not the real Client IP. What's the best way to set https:FFI: How to pass a pointer to a char pointer?How can I pass a pointer to a char pointer in order to use the C function below via FFI? ```c my_funDeno.serve().shutdown doesn't exist?```ts const server = Deno.serve({ hostname, port, }) server.shutdown() ``` ``` error: TS2339 [EDeno deploy see errorHow can i see the error why my build failed? It just returned `Error An internal server error occurrIn-browser testingI need to run some tests in a browser (Chrome, Firefox, Safari). Either by running a full test suiteCannot pass request object to workerI am trying to pass a request object to a worker file, but it is not receiving it inside of the workDoes the picture plugin for lume work with remote Images?I want to use the picture plugin with images that are from a remote location. Is there a way to get problem with prompt on windowsHi, I'm experiencing trouble when inputting 2 char long strings in prompt, it's doing \rDuplicate tailwind classes in Fresh projectAcross the board I'm seeing tailwind classes duplicated in my Fresh project. There doesn't seem to bTrouble accessing Deno KV via the Deno CLII'm trying to connect to a Deno KV via the CLI with the following simple code: ```ts //main.ts consBest way for application config in deno/ts?Hi. I'm alex and quite new to deno/typescript. Thank you for the quite big documenation it is a quitError trying to connect: Connection reset by peer (os error 104)Hello, i'm trying to deploy a my Fresh website using a Ubuntu 22.04 server but when I try to run my 500 on deno.land/x/fp_ts with ?s=eitherThe actual URL is https://deno.land/x/fp_ts@v2.11.4/mod.ts?s=eitherDeno.test without Deno namespace ?Hi there, Does someone know if it's possible to run a test from `Deno.test` without the Deno namesp