Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
};
const { PHASE_DEVELOPMENT_SERVER } = require("next/constants");

module.exports = nextConfig;
/**
* Multizone embedding via assetPrefix.
*
* The chat is embedded on policyengine.org/uk/chat as a multizone child
* (see policyengine-app-v2 PR #1036). Static asset URLs in the generated
* HTML get the "/_zones/uk-chat" prefix so the website (policyengine.org)
* can proxy them back from the chat host via a Vercel rewrite:
*
* /uk/chat → chat-host/
* /_zones/uk-chat/_next/:path* → chat-host/_zones/uk-chat/_next/:path*
*
* On the chat host, `vercel.json` rewrites the prefixed asset URLs back to
* the unprefixed paths Next.js actually serves from. Pages still live at "/"
* so the standalone preview URL (policyengine-uk-chat.vercel.app) keeps
* working. Matches the household-api-docs zone pattern.
*
* Dev server runs without the prefix so local development stays simple.
*/
module.exports = (phase) => {
const isDev = phase === PHASE_DEVELOPMENT_SERVER;
/** @type {import('next').NextConfig} */
return {
output: "standalone",
assetPrefix: isDev ? undefined : "/_zones/uk-chat",
};
};
8 changes: 8 additions & 0 deletions frontend/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rewrites": [
{
"source": "/_zones/uk-chat/_next/:path*",
"destination": "/_next/:path*"
}
]
}