D
Deno

help

proxy-agent not working on Deno Deploy

IIngilizAdam9/16/2023
I'm trying to use a proxy for the node-fetch requests in a deno app. I chose proxy-agent npm package and its working great on my local. It reads HTTP_PROXY environment variable and uses that host as the proxy. But when I deploy my app in Deno Deploy, proxy is not working. I set the environment variable correctly but proxy-agent is just ignoring that? I appreciate any help.
DAHDeno AI Helper9/16/2023
Based on the documentation, Deno Deploy does not currently support all npm packages. While Deno Deploy does support importing built-in Node.js modules, it does not support all npm packages. The proxy-agent package you're trying to use is not a built-in Node.js module, so it might not be supported in Deno Deploy. Deno Deploy does support proxies for module downloads and the Web standard fetch API. Proxy configuration is read from environmental variables: HTTP_PROXY, HTTPS_PROXY and NO_PROXY. However, this is different from using a proxy within your application logic, which seems to be what you're trying to do with proxy-agent. If you're trying to create a proxy server, the documentation provides an example of how to create a basic HTTP proxy server using the fetch API:
import { serve } from "https://deno.land/std/http/mod.ts";
async function reqHandler(req: Request) {
const reqPath = new URL(req.url).pathname;
return await fetch("https://example.com" + reqPath, { headers: req.headers });
}
serve(reqHandler, { port: 8000 });
import { serve } from "https://deno.land/std/http/mod.ts";
async function reqHandler(req: Request) {
const reqPath = new URL(req.url).pathname;
return await fetch("https://example.com" + reqPath, { headers: req.headers });
}
serve(reqHandler, { port: 8000 });
In this example, all requests are proxied to https://example.com. If you're trying to use a proxy for outgoing requests from your application, you might need to use a different approach, as proxy-agent might not be supported in Deno Deploy. Unfortunately, the documentation does not provide a clear answer on how to do this. 🦕
IIngilizAdam9/16/2023
But proxy-agent is working on my local, so deno supports it. But apparently Deno Deploy doesn't? Isn't it weird that Deno supports it but Deno Deploy service doesn't? Are we sure this is the problem here?
Ffinancesaucer1/15/2024
Hi, did you find a way to make it work?
IIngilizAdam1/15/2024
sadly no it just doesnt work when published but works in local
Ffinancesaucer1/15/2024
For me too, even createHttpClient doesnt work because its unstable api and i cant find any other way to make it work... i guess the only way is to self host the sever
IIngilizAdam1/15/2024
yeah that seems like it

Looking for more? Join the community!

Recommended Posts
Extremely high CPU usage in Windows running on Intel Pentium processorI have a simple app (about 300 lines of code, few deps). I compile it into a Windows executable. WheImpossible to use `"jsx": "preserve"` in deno.json...Well it seems that I can't use jsx preserve in deno.json, when I try to run any tasks in deno.json, integrating deno_webOk I seem to have poobrain today. Can't seem to get the deno_web extension working. The core versioCan I use Workers in an executable ?Everything is in the questions, on the doc site, it is mention that we can't use Workers when creatiWalkSync dosnt get filesIm trying to read all files of a folder with WalkSync from the deno STD libary but it dosnt see thedeno behaving differently in local dev env and production docker buildsI'm currently trying to switch from using node+yarn 2 for my blogs static files to deno. however theFront end dev needed for 6 months.Hello. I am in need of a frontend developer. dm me pls.Include platform and version in compiled binary filenameRight now when i run `deno compile --output bin/myprogram`, it works as expected. Is is possible to How to handle a user abort by Deno.serveHello, I have a question and discovered this Discord channel now. The Deno website has an example atAPI hooks during restart for deno run --watchHello! I thought it would be super fun to further minimize repetitive tasks while manually testing adeno compile -A npm:cowsay not workingHello, I am trying `deno compile -A npm:cowsay` and then following that with `./cowsay Hello World!`compiling issue with import { WebSocketServer } from "npm:ws@^8.14.1"Using this impot in a "deno run --unstable [etc...]" env works flawless / as intended but trying to Is there any way to get Deno to not statically analyze import()?I understand that statically analyzing and fetching dynamic import() calls is a good thing for perfoUsing Deno in Frontend.Hey, I was wandering if it is possible to use Deno for Vanilla Frontend development. I dont want to Excluding certain directories when using "walk"Hello, I'm writing a script that should crawl through a directory and search for a given text insideSyntax Error: Unexpected token 'export'Hello, We are using Supabase Deno Edge Functions and are getting this error while trying to import a