setup admin panel proxy
Attaching the admin panel on your website is an easy step
This ensures your editing experience is seamless. With the admin panel attached to your website via a proxy, you can edit your website on the same URL and have a visual preview of the changes in real time. It also enables overlay editing which is a better user experience in editing the webpage.
The proxy setup is just a proxy.ts file in your project which behaves like a URL rewrite, to allow /admin endpoint of your website to resolve to the CMS.
localhost: you must use a tunnel (since CMS cannot access localhost directly)// proxy.ts
import { createCmsProxy } from 'cms-renderer/lib/proxy';
export const proxy = createCmsProxy({
upstream:
Now you can go to: /admin to access the admin panel from your website. This enables live preview.
The overlays are handled automatically. You just need to pass searchParams into your renderer.
// page.tsx
interface PageProps {
params: Promise<{ slug: string[] }>;
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
}
export default async function Page({ params, searchParams }: PageProps) {
const { slug } = await params;
return (
<ParametricRoutePage
registry={registry}
apiKey="sk_..."
websiteId="a2717ba3-29db-..."
cmsUrl={"https://cms.dev.tryprofound.com"}
params={Promise.resolve({ slug })}
searchParams={searchParams}
/>
);
}
/admin on your websiteOverlays and live previews should work automatically.