Skip to content

Error overlay copy button doesn't work #33872

Closed

Description

@onmax

Description

The copy button in the error overlay fails with TypeError: Cannot read properties of undefined (reading 'writeText').

Root Cause

The error overlay renders youch's error page inside a data: URL iframe. data: URLs have an opaque origin which is not a secure context, so navigator.clipboard is undefined.

Reproduction

https://github.com/onmax/clipboard-repro

git clone https://github.com/onmax/clipboard-repro
cd clipboard-repro
pnpm install
pnpm dev

Visit http://localhost:3000 → click copy button → check console.

Solution

Use postMessage to delegate clipboard operations to the parent window (which has secure context).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions