Skip to content

Enable multizone embedding via prefixed asset URLs#96

Open
SakshiKekre wants to merge 1 commit into
mainfrom
chore/multizone-asset-prefix
Open

Enable multizone embedding via prefixed asset URLs#96
SakshiKekre wants to merge 1 commit into
mainfrom
chore/multizone-asset-prefix

Conversation

@SakshiKekre
Copy link
Copy Markdown
Collaborator

@SakshiKekre SakshiKekre commented Jun 2, 2026

What

Makes the chat embeddable as a multizone child on `policyengine.org/uk/chat` (see policyengine-app-v2 PR #1036). Matches the household-api-docs zone pattern.

How

Two files:

  • `frontend/next.config.js`: `assetPrefix: '/_zones/uk-chat'` in production builds (unprefixed in dev). Generated HTML references assets at `/_zones/uk-chat/_next/static/` instead of `/_next/static/`.
  • `frontend/vercel.json`: rewrite `/_zones/uk-chat/_next/:path*` → `/_next/:path*` so the chat host can fulfil those prefixed asset URLs without needing `basePath` (which would break the standalone preview URL).

End-to-end flow once both this and PR #1036 merge

The website (policyengine.org) rewrites:

```
/uk/chat → chat-host/
/_zones/uk-chat/_next/:path* → chat-host/_zones/uk-chat/_next/:path*
```

  1. User opens `policyengine.org/uk/chat`
  2. Website serves chat-host's HTML (chat's pages still live at `/`)
  3. HTML references assets at `/_zones/uk-chat/_next/static/*` (because of `assetPrefix`)
  4. Browser requests those from `policyengine.org/_zones/uk-chat/_next/static/*`
  5. Website rewrites to `chat-host/_zones/uk-chat/_next/static/*`
  6. Chat host's `vercel.json` strips the prefix back off → serves from `/_next/static/*`

What stays the same

Test plan

  • Preview builds successfully
  • Vercel preview at `policyengine-uk-chat-git-chore-multizone-asset-prefix-policy-engine.vercel.app` loads the chat
  • DevTools network tab shows assets requested at `/_zones/uk-chat/_next/static/*` and returning 200
  • Once merged + PR #1036 merged + production deploys settle, `policyengine.org/uk/chat` loads the chat with no console asset 404s

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-uk-chat Ready Ready Preview, Comment Jun 2, 2026 5:42pm

Request Review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

Beta preview is ready.

The chat is being embedded on policyengine.org/uk/chat as a multizone
child (see policyengine-app-v2 PR #1036). Vercel rewrites are the
mechanism; cross-origin iframes blank out for Next.js apps per
CLAUDE.md.

For the rewrites to work end-to-end, the chat's static asset URLs
need to live under a prefixed path so the website can proxy them
back through policyengine.org. Matches the household-api-docs zone
pattern (which uses the same /_zones/<name> convention).

Two coordinated files:

- frontend/next.config.js: assetPrefix '/_zones/uk-chat' in production
  builds. Dev server stays unprefixed for local development.
- frontend/vercel.json: rewrite /_zones/uk-chat/_next/:path* back to
  /_next/:path* so the chat host serves the prefixed URLs that the
  generated HTML references, without needing basePath (which would
  break the standalone preview URL).

Pages still live at "/" on the chat host, so direct previews
(policyengine-uk-chat.vercel.app) keep working unchanged.
@SakshiKekre SakshiKekre force-pushed the chore/multizone-asset-prefix branch from 1432dfc to 41a5ed5 Compare June 2, 2026 17:41
@SakshiKekre SakshiKekre changed the title Enable multizone embedding via NEXT_PUBLIC_CHAT_ASSET_PREFIX Enable multizone embedding via prefixed asset URLs Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant