Skip to content

fix(launchpad): QR code encodes the page's own URL - #59

Merged
onamfc merged 1 commit into
mainfrom
launchpad-qr-page-url
Sep 17, 2026
Merged

onamfc merged 1 commit into
mainfrom
launchpad-qr-page-url

Conversation

@onamfc

@onamfc onamfc commented Sep 17, 2026

Copy link
Copy Markdown
Member

The Launchpad page's QR image was requested as /api/links/{id}/qr?format=svg&size=264, so the QR route fell back to SHORTLINK_DOMAIN/{shortCode}. For a link served on another host or under a template path (/{slug}/{code}), the phone was sent somewhere other than the page the visitor was looking at, and the visitor's query string never made the hop.

Change

  • renderLaunchpadPage passes pageUrl as a url query parameter on the QR image.
  • The redirect builds pageUrl from the request host, the template path and the visitor's query string (dropped entirely when longer than 512 characters, so the code stays scannable). og:url gets the same value.
  • GET /api/links/:id/qr accepts url. It is restricted to http(s) URLs whose path ends in /{shortCode} of that link — the link on any host, under any path, with any query — and anything else is a 400, so the endpoint cannot mint codes for arbitrary destinations. The cache key includes it. Without url, behavior is unchanged.

Testsqr.test.ts (new, 5): the guard's accept/reject cases, a 200 for a templated custom-host URL, a 400 for a foreign destination, the unchanged fallback. redirect.launchpad.test.ts (+2): host + template path + query string reach the QR url, and an over-long query is dropped. 389 passing.

README: url documented under QR Codes.

…AIN/{shortCode}

The page's QR image was requested without a url, so the QR route encoded
SHORTLINK_DOMAIN plus the bare short code. A visitor on a custom host, or on
a templated path, scanned a code that pointed somewhere else — and any query
string they arrived with was lost in the hop to the phone.

The page now passes its own address (host, template path, query string up to
512 characters) as the QR route's new url parameter. The parameter is
restricted to http(s) URLs whose path ends in that link's short code, so the
endpoint cannot be used to mint codes for arbitrary destinations; the cache
key includes it.
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/routes/qr.ts 97.29% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@onamfc
onamfc merged commit a10dc0b into main Sep 17, 2026
14 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant