PolicyEngine / PolicyEngine/policyengine-app-v2

fix: Report sharing URLs use production prefix in preview environments

Open
#580 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
1
Forks
3
Avg merge
1d 50m
Merged PRs (30d)
39

Description

Parent issue: #579

Summary

When sharing reports from Vercel preview deployments, the generated shareable URLs use the production domain prefix (app.policyengine.org) instead of the preview deployment URL.

Current Behavior

In a preview environment (e.g., policyengine-calculator-abc123.vercel.app):

  • User creates/views a report
  • User clicks "Share" or copies the report URL
  • Generated URL: https://app.policyengine.org/us/report-output/12345

Why This Matters

  • Database is shared: Preview and production use the same API/database, so the report ID exists and loads
  • Missing features: Production doesn't have features under development that exist in the preview
  • Testing broken: Teammates testing a preview can't share links that point to the preview environment
  • Confusing UX: Developers think they're testing new features but shared links go to old production code

Expected Behavior

In a preview environment:

  • Generated URL: https://policyengine-calculator-abc123.vercel.app/us/report-output/12345

Technical Notes

  • BASE_URL in constants.ts is hardcoded to https://api.policyengine.org (API endpoint - correct)
  • Need separate handling for app URLs used in shareable links
  • Should detect if running in Vercel preview and use VERCEL_URL environment variable
  • Related to #565 which handles cross-app navigation URLs

Acceptance Criteria

  • Report share URLs in preview environments point to preview deployment
  • Production behavior unchanged
  • Local development uses localhost URLs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with constants.ts and trace the code that builds report share URLs, checking how the app distinguishes production, Vercel preview, and local environments. Review the Vercel environment variables, especially VERCEL_URL, and verify that preview links use the deployment URL, production remains unchanged, and local links use localhost.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.