{"id":49786,"library":"x-forwarded-fetch","title":"x-forwarded-fetch","description":"A small middleware for fetch() that adjusts request URLs based on X-Forwarded-Host and X-Forwarded-Proto headers when running behind a reverse proxy. Version 0.2.0, stable. Key differentiator: lightweight, zero-dependency, works across Deno, Bun, and Node.js (uses @hono/node-server). Handles proxy-aware URL reconstruction without modifying existing fetch handlers.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/dahlia/x-forwarded-fetch","tags":["javascript","fetch","proxy","reverse proxy","x-forwarded-host","x-forwarded-proto","typescript"],"install":[{"cmd":"npm install x-forwarded-fetch","lang":"bash","label":"npm"},{"cmd":"yarn add x-forwarded-fetch","lang":"bash","label":"yarn"},{"cmd":"pnpm add x-forwarded-fetch","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for Node.js integration to serve HTTP; not needed for Deno or Bun.","package":"@hono/node-server","optional":true}],"imports":[{"note":"ESM only; named export.","wrong":"import behindProxy from 'x-forwarded-fetch'","symbol":"behindProxy","correct":"import { behindProxy } from 'x-forwarded-fetch'"},{"note":"TypeScript users can import the FetchHandler type.","wrong":"","symbol":"None (type)","correct":"import type { FetchHandler } from 'x-forwarded-fetch'"},{"note":"Deno uses JSR package registry; path includes scope.","wrong":"","symbol":"Deno import","correct":"import { behindProxy } from '@hongminhee/x-forwarded-fetch'"}],"quickstart":{"code":"import { behindProxy } from 'x-forwarded-fetch';\nimport { serve } from '@hono/node-server';\n\nconst handler = behindProxy((req) => {\n  const url = new URL(req.url);\n  return new Response(`Original URL: ${url.href}`);\n});\n\nserve({\n  fetch: handler,\n  port: 3000\n});","lang":"typescript","description":"Node.js example: wraps a fetch handler with behindProxy to show proxied URL."},"warnings":[{"fix":"Use '@hongminhee/x-forwarded-fetch' in Deno, 'x-forwarded-fetch' in Bun/Node.","message":"Import path differs between Deno (@hongminhee/x-forwarded-fetch) and npm (x-forwarded-fetch). Using the wrong path causes module not found.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"If you need other X-Forwarded-* headers, combine with additional middleware.","message":"behindProxy only handles X-Forwarded-Host and X-Forwarded-Proto. Other headers like X-Forwarded-For are ignored.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Pin version to avoid unexpected changes.","message":"Version 0.x may have breaking changes in minor releases.","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.2.0':33 'across':42 'adjust':11 'awar':52 'base':14 'behind':28 'bun':44 'deno':43 'depend':40 'differenti':36 'exist':57 'fetch':4,9,58,61 'forward':3,18,23,67,71 'handl':49 'handler':59 'header':25 'hono/node-server':48 'host':19,68 'javascript':60 'key':35 'lightweight':37 'middlewar':7 'modifi':56 'node.js':46 'proto':24,72 'proxi':31,51,62,64 'proxy-awar':50 'reconstruct':54 'request':12 'revers':30,63 'run':27 'small':6 'stabl':34 'typescript':73 'url':13,53 'use':47 'version':32 'without':55 'work':41 'x':2,17,22,66,70 'x-forwarded-fetch':1 'x-forwarded-host':16,65 'x-forwarded-proto':21,69 'zero':39 'zero-depend':38","created_at":"2026-06-07T17:03:35.779423+00:00","updated_at":"2026-06-07T17:03:35.779423+00:00","problems":[{"fix":"Use 'x-forwarded-fetch' instead of '@hongminhee/x-forwarded-fetch'.","cause":"Trying to use the Deno import path in Node.js or Bun.","error":"Module not found: \"@hongminhee/x-forwarded-fetch\""},{"fix":"Use import { behindProxy } from 'x-forwarded-fetch'.","cause":"Using default import instead of named import.","error":"behindProxy is not a function"},{"fix":"Ensure the proxy sends headers and that the handler is wrapped: behindProxy(yourHandler).","cause":"Request might not have X-Forwarded headers, or fetch handler is not wrapped correctly.","error":"Request URL is not being modified"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/dahlia/x-forwarded-fetch","github":"https://github.com/dahlia/x-forwarded-fetch","docs":null,"changelog":null,"pypi":null,"npm":"x-forwarded-fetch","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}