Skip to content

feat(share): public share-link backend (/api/share + /s/[id]) - #10

Merged
1bcMax merged 1 commit into
masterfrom
feat/share-link
Jun 4, 2026
Merged

feat(share): public share-link backend (/api/share + /s/[id])#10
1bcMax merged 1 commit into
masterfrom
feat/share-link

Conversation

@KillerQueen-Z

Copy link
Copy Markdown
Collaborator

What

The server half of the Franklin Desktop 复制链接 / Copy-link feature. The desktop app already has the button; it POSTs the selected conversation to `franklin.run/api/share` and copies the returned URL — but that route doesn't exist in production yet, so today the button shows "分享失败". This PR adds it.

Changes

  • `POST /api/share` (route.ts) — stores the selected conversation snapshot, returns `{ id, url }` → `https://franklin.run/s/`.
    • Public + CORS-enabled (the desktop renderer has only a local wallet, no web session cookie, so creating a share is unauthenticated).
    • Capped: ≤200 messages, ≤2 MB. Cleans fields; only inline `data:` images travel (local `127.0.0.1` media is stripped — it would 404 for anyone else).
  • `/s/[id]` (page.tsx) — public, read-only, `noindex` render of a shared conversation, reusing the `/try` `MessageContent` renderer + a CTA back to Franklin.
  • `share-store.ts` (share-store.ts) — immutable snapshots under a public `franklin-share/` GCS prefix (unguessable ~96-bit id); local-dev fs fallback (`FRANKLIN_STORE_LOCAL=1`), mirroring `franklin-store.ts`.

Security model

Unguessable id + immutable snapshot = you can only ever read what you were handed a link to. Open-create is acceptable for now; add rate-limiting before a wide public launch.

Deploy

Requires deploy to franklin.run for the desktop button to work live. Local test: `FRANKLIN_STORE_LOCAL=1 npm run dev` and point the desktop at `http://localhost:3000/api/share\`.

Adds the server half of the desktop 复制链接 (copy-link) feature:

- POST /api/share — stores the selected conversation snapshot and returns
  a https://franklin.run/s/<id> URL. Public + CORS-enabled (the desktop
  renderer has a local wallet, no web session), size/message capped, only
  inline data: images travel (local 127.0.0.1 media is stripped).
- /s/[id] — public, read-only, noindex render of a shared conversation,
  reusing the /try MessageContent renderer, with a CTA back to Franklin.
- share-store.ts — immutable snapshots under a public franklin-share/
  GCS prefix (unguessable ~96-bit id); local-dev fs fallback, mirroring
  franklin-store.

Deploy required for the desktop button to work live.
@1bcMax
1bcMax merged commit c039111 into master Jun 4, 2026
1 check passed
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