Skip to content

Self-hosted (Tier 2) publishing to Bluesky doesn't work off the loopback origin #37

Description

@jpdevries

Summary

Share to Bluesky (shipped in v0.5.0, #33) renders on the self-hosted Rex app, but a real publish only completes when the instance is reached at http://127.0.0.1:3000. A self-hoster hitting their box at its real address (LAN IP, Tailscale hostname, a reverse-proxied domain) can't complete OAuth sign-in.

Why

The publish feature is entirely client-side (browser → PDS); the Rust backend is not involved. The OAuth client_id is chosen by origin in packages/shared/src/contexts/BlueskyAuth.tsx:

Origin client_id Real publish
127.0.0.1 / [::1] spec loopback client
localhost — (warns, bails; spec requires 127.0.0.1)
any other origin falls back to hosted https://pantryhost.app/client-metadata.json ❌ redirect_uri mismatch

The hosted client metadata's redirect_uris list only pantryhost.app / my.pantryhost.app, so the AT authorization server rejects a redirect back to a self-hosted address.

There's a getProdClientId() override, but it only reaches the browser via VITE_ATPROTO_CLIENT_ID at build time (Tier 1's Vite build). The Rex/app path reads process.env.ATPROTO_CLIENT_ID, which Rex does not inline into the client bundle — the same limitation that forced the dry-run flag onto a <meta> channel in _document.tsx.

What it would take (no Rust)

  1. A runtime channel so ATPROTO_CLIENT_ID reaches the Rex client — a <meta name="atproto-client-id"> tag in packages/app/pages/_document.tsx, mirroring the atproto-publish-dry-run fix; getProdClientId() reads it browser-side.
  2. The self-hoster serves their own client-metadata.json at a public HTTPS URL whose redirect_uris include their instance's callback (AT OAuth requires the client_id to be a publicly-resolvable HTTPS document). Needs docs + ideally a helper to generate the metadata.

Until then, document that self-hosted publishing works via http://127.0.0.1:3000 on the box itself, and defaults to safe dry-run everywhere else.

Related

Cross-device publish-state reconcile: #36

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions