Skip to content

Copy Link button hardcodes the production URL instead of using getSiteUrl() #2

Description

@royalpinto007

The "Copy Link" button on a case page builds the copied URL from a hardcoded string:

components/post/CopyLinkButton.tsx

navigator.clipboard.writeText(
  `https://agentpostmortem.com/case/${caseNumber}`,
);

The repo already has a helper for this in lib/utils/urls.ts (getSiteUrl()), which prefers NEXT_PUBLIC_SITE_URL, falls back to NEXT_PUBLIC_APP_URL, strips trailing slashes, and only then falls back to the production domain. Two problems with the hardcoded version: copying a link while developing on localhost:3000 gives you a production URL, and the canonical site is www.agentpostmortem.com while the button emits the apex domain.

What to do

  1. Import getSiteUrl from @/lib/utils/urls in components/post/CopyLinkButton.tsx.
  2. Use it to build the copied URL: ${getSiteUrl()}/case/${caseNumber}.
  3. Check whether any other component hardcodes https://agentpostmortem.com in client code and fix those the same way (grep -rn "https://agentpostmortem.com" components app). Leave the intentional default inside lib/utils/urls.ts alone.

Verify

npm run lint
npx tsc --noEmit
npm run format
npm test

Then run npm run dev, open any case page, click Copy Link, and confirm the pasted URL points at your local origin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions