Skip to content

feat: support multi-page website navigation in gateway iframe sandbox #23

@sanity

Description

@sanity

Problem

The gateway serves web container content inside a sandboxed iframe with allow-scripts allow-forms allow-popups (no allow-top-navigation, no allow-same-origin). This works for single-page apps (like River) where all routing happens in JavaScript, but breaks multi-page static websites where links navigate between HTML pages.

When a user clicks a link like <a href="/v1/contract/web/KEY/news/">, the navigation is silently blocked by the sandbox. Neither regular link clicks nor window.location.href assignments work.

Impact

Static websites published with fdev website publish render correctly on the first page load, but internal navigation between pages doesn't work. This significantly limits the usefulness of the website hosting feature for multi-page sites (which is most static sites).

Current workaround

Users must navigate by editing the URL directly in the browser address bar. This is unusable for non-technical visitors.

Possible solutions

  1. Add allow-same-origin to the sandbox -- simplest but may have security implications that need evaluation
  2. Gateway-side navigation interception -- the freenetBridge script could listen for postMessage navigation requests from the iframe and update the iframe's src
  3. Rewrite links at serve time -- the gateway could inject JavaScript into served pages that intercepts clicks and communicates with the bridge via postMessage

Option 2 seems most promising -- the iframe posts a {type: 'navigate', href: '/news/'} message, and the bridge updates the iframe src accordingly. This preserves the sandbox security model while enabling navigation.

[AI-assisted - Claude]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions