Go to file
dependabot[bot] a351b962c4
chore(deps): bump actions/checkout in the github-actions group
Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout).


Updates `actions/checkout` from 4 to 5
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-17 10:49:07 +00:00
.github chore(deps): bump actions/checkout in the github-actions group 2025-08-17 10:49:07 +00:00
src fix: add logging and error handling 2025-07-21 13:39:55 +02:00
.editorconfig feat: add supporting files 2025-02-07 15:15:42 +01:00
.gitignore feat: initial project setup 2025-02-07 13:43:34 +01:00
biome.json chore: update setup 2025-02-07 15:56:36 +01:00
bun.lock chore: update setup 2025-02-07 15:56:36 +01:00
bunfig.toml chore: update setup 2025-02-07 15:56:36 +01:00
LICENSE chore: update setup 2025-02-07 15:56:36 +01:00
package.json fix: add logging and error handling 2025-07-21 13:39:55 +02:00
README.md docs: add license 2025-02-07 16:03:34 +01:00
tsconfig.json feat: initial project setup 2025-02-07 13:43:34 +01:00

npm npm Build Status

@foomo/next-proxy-middleware

A Next.js middleware for proxying requests to external services with advanced configuration options.

Installation

npm install @foomo/next-proxy-middleware

Usage

Import the middleware and configuration type in your Next.js middleware file:

import {
  createProxyMiddleware,
  DevProxyConfig,
} from "@foomo/next-proxy-middleware";

Configuration

The DevProxyConfig type defines the following options:

export type DevProxyConfig = {
  debug?: boolean; // Enable debug logging
  disable?: boolean; // Disable the proxy entirely
  remoteUrl: string | ((request: NextRequest) => string); // Remote URL or function to generate it
  allowResponseCompression?: boolean; // Allow response compression (default: false)
  overrideHostHeader?: boolean; // Override host header (default: true)
  overrideCookieDomain?: false | string; // Domain to use for cookies or false to disable
  basicAuth?: {
    authHeader: string; // Authorization header value
  };
  cfTokenAuth?: {
    clientId: string;
    clientSecret: string;
  };
};

Example

Here's an example of how to use the middleware in your middleware.ts file:

import {
  createProxyMiddleware,
  DevProxyConfig,
} from "@foomo/next-proxy-middleware";

const proxyConfig: DevProxyConfig = {
  remoteUrl: "https://api.example.com",
  basicAuth: {
    authHeader: "Basic abc123==",
  },
  overrideCookieDomain: "example.com",
};

export function middleware(request: NextRequest) {
  if (request.nextUrl.pathname.match("^/(api|webhooks)/")) {
    return proxyMiddleware(request);
  }
  return request;
}

export const config = {
  matcher: ["/api/:path*"],
};

const proxyMiddleware = createProxyMiddleware(proxyConfig);

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

License

Distributed under MIT License, please see license file within the code for more details.

Made with ♥ foomo by bestbytes