admin-proxy

Open the Median admin panel at yoursite.com/admin with the cms-renderer proxy

Your team can open the Median admin panel on your own website, at https://yoursite.com/admin, instead of app.mediancms.com. Your site forwards /admin and the requests the admin panel makes to Median, and Median recognises which website it is serving from the domain. Editors stay on your domain: sign-in returns there, and cookies are set there.


Before you start

  1. Set your website's domain in Settings β†’ Websites (for example yoursite.com). Median uses it to tell which website a forwarded request belongs to.
  2. Use cms-renderer 2.0.1 or later:
npm install cms-renderer@latest

What gets forwarded

createCmsProxy from cms-renderer/proxy decides per request. It forwards only paths that belong to Median:

  • /admin and everything under it
  • the admin panel's files and calls: /cms-assets/…, /cms-fn/…, /login, /logout, /monitoring
  • Median's own API routes: /api/trpc/…, /api/auth/… and the others the admin panel uses, each by name
  • /favicon.svg, /manifest.webmanifest, /brand/… and /wasm/…, only when an /admin page asks for them

Everything else, including your own /api/… routes and your own favicon, stays with your site. For any other path the proxy returns null, and your framework handles the request as usual.

Next.js

Next.js 16 runs src/proxy.ts before matching requests (in Next.js 15 and earlier the file is middleware.ts and the function is middleware):

// src/proxy.ts
import { createCmsProxy } from 'cms-renderer/proxy';
import { type NextRequest, NextResponse } from 'next/server';

const cmsProxy = createCmsProxy();

export async function proxy(request: NextRequest) {
  return (await cmsProxy(request)) ?? NextResponse.next();
}

export const config = {
  matcher: [
    '/admin/:path*',
    '/cms-assets/:path*',
    '/cms-fn/:path*',
    '/login',
    '/logout',
    '/monitoring/:path*',
    '/api/:path*',
    '/wasm/:path*',
    '/brand/:path*',
    '/favicon.svg',
    '/manifest.webmanifest',
  ],
};

The matcher only keeps Next.js from running the proxy on every page; createCmsProxy still decides which of these requests are Median's.

TanStack Start

Add a request middleware in src/start.ts. It sees every request, in development and in production:

// src/start.ts
import { createMiddleware, createStart } from '@tanstack/react-start';
import { createCmsProxy } from 'cms-renderer/proxy';

const proxy = createCmsProxy();

const cmsProxyMiddleware = createMiddleware().server(
  async ({ request, next }) => (await proxy(request)) ?? next()
);

export const startInstance = createStart(() => ({
  requestMiddleware: [cmsProxyMiddleware],
}));

Any other server

The proxy takes a standard Request and returns a Response or null, so it fits any server built on the Fetch API (Hono, Remix, Bun, Deno, Cloudflare Workers):

const proxy = createCmsProxy();
const response = (await proxy(request)) ?? (await yourSite(request));

Options

OptionDefaultUse
upstreamhttps://app.mediancms.comA self-hosted Median admin panel.

Check it works

curl -sI https://yoursite.com/admin | grep -iE '^(HTTP|location|x-proxied-by)'

Signed out, you should see a redirect to /login on your domain and the header x-proxied-by: cms-proxy. Then open https://yoursite.com/admin in the browser and sign in.

Troubleshooting

  • 404 on /admin. The proxy is not running: check the file name and location (src/proxy.ts next to src/app, or src/start.ts), and that the matcher includes /admin/:path*.
  • Signed in, but the wrong website or no website. The domain in Settings β†’ Websites must match the domain you open, without https:// or a trailing slash.
  • Blank admin panel. Its files are not getting through: make sure /cms-assets/:path* and /cms-fn/:path* are in the matcher.
  • Your own /api route stopped working. It cannot be one of Median's route names (/api/trpc, /api/auth, …); everything else under /api stays yours.