A lightweight reverse proxy built with Next.js, designed to proxy requests from a subdirectory path to a target URL. Deployable to Webflow Cloud.
This proxy is useful when you want to serve content from an external URL under a subdirectory of your domain. For example, you can proxy yourdomain.com/help to external-helpdesk.com/help, making the external content appear as part of your site.
- Proxies all HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)
- Forwards request headers and body
- Handles hop-by-hop headers correctly
- Preserves query strings
- Handles redirects manually to maintain proxy integrity
- Deployable to Webflow Cloud for edge performance
- Node.js 18+
- npm or yarn
npm install- Copy the example environment file:
cp .env.example .env- Set your target URL in
.env:
PROXY_TARGET_URL=https://www.example.com/help- Update
next.config.jsto match your desired subdirectory path:
const nextConfig = {
basePath: "/help",
assetPrefix: "/help",
};npm run devnpm run build
npm startThis project is configured to deploy to Webflow Cloud using OpenNext.
Preview locally:
npm run previewMake sure to set the PROXY_TARGET_URL environment variable in your local and deployed environments.
| File | Purpose |
|---|---|
next.config.js |
Next.js configuration with basePath and assetPrefix |
wrangler.jsonc |
Cloudflare Workers configuration |
open-next.config.ts |
OpenNext configuration for Cloudflare |
MIT License - see LICENSE.md for details.