GuidesUpdated

AI-built app works locally but fails on Vercel Preview

Find where a working Canopy run and a broken Vercel Preview first differ: commit, build, environment variables, runtime request or backend target.

On this page

Your app works locally in Canopy but fails on a Vercel Preview. Find the first point where the two environments diverge before asking an agent to rewrite code. The example is a report form that saves locally but errors on a PR preview. The same order works on other hosts, with their own logs.

Canopy local service output and preview beside the project workspace
Canopy local service output and preview beside the project workspace

Pin the local and deployed versions

Record the local checkout and commit, the PR head, the Vercel project and environment, and the deployment URL and commit. Vercel's branch URLs follow the latest deployment; commit URLs point at one build, so use those to reproduce. Your local server may be running a different worktree or port. In Canopy, check the service's directory and URL beside the agent's checkout. Don't compare an uncommitted edit with an older preview.

Capture both sides before investigating the broken report form.
BoundaryLocal evidenceVercel evidence
CodeCheckout and commit or uncommitted diffDeployment commit and PR head
RunCommand, port, and local URLBuild status and deployment URL
ConfigurationVariable names and backend targetPreview variable names and backend target
FailureForm request and observed responseSame form request, response, and relevant logs

Separate a failed build from a failed request

If the deployment didn't build, find the first actionable error in its build logs, above the final exit line. Run the production build locally to reproduce code or dependency errors. If it built but a request fails, reproduce it in the browser and note the status, path and sanitized response. Then check Vercel runtime logs for that function call; build logs won't explain it.

  • Classify the failure: build, browser, server function or external service.
  • Don't paste full private logs into a public prompt.

Compare Preview settings with local inputs

Local, Preview and Production can have different variables and services. For the report form, compare variable names, scopes and the database project used locally with those on this Preview. The owner confirms values in Vercel's settings, without showing raw secrets to an agent. Also check the project root, build command, runtime and lockfile. After changing a setting, redeploy and test the new URL; old deployments keep their old configuration.

  • Check the variable is set for Preview, and for the branch if scoped.
  • Never point a preview at production data to make it work.

Trace the same request through the backend

Send the same input with a test account on both sides. Check the browser Network entry, the function log and the downstream record. A 404 may mean the route didn't deploy; a 500 needs server logs; a success with no saved report points at the data target. A database or worker has its own logs. For auth redirects or webhooks, confirm the external service allows the preview URL.

  • Tie each observation to one time, path, role and commit.
  • After a fix, test one save and one error path.

Give the agent a narrow fix and test the new deployment

Give the agent the commit, reproduction, sanitized error and the difference you found. Ask it to diagnose before editing and change only the relevant code or configuration. Owners change secrets, database permissions and production settings. Then repeat the request on the new commit Preview, check the saved record and read the runtime logs before deciding to merge.

  • A successful redeploy isn't a tested user journey.
  • Record what changed: code, environment, service or all three.
  • Check Production separately after merge.

Copyable resources

Local-versus-Preview failure report

Redact tokens, personal data and private response bodies before sharing with an agent or issue.

Local checkout / commit / port / URL: [ ]
PR head and commit-specific Preview URL: [ ]
Vercel project and environment: [ ]
Same action and test account role on both sides: [ ]
Local response: [ ]
Preview response and timestamp: [ ]
Build status and first build error, if any: [ ]
Runtime route and sanitized log, if any: [ ]
Variable names and backend project IDs compared by owner: [ ]
Diagnosis: build / browser / function / external service / unknown
Proposed fix and owner: [ ]
New deployment commit and retest result: [ ]

Frequently asked questions

Why does my local app work while Vercel Preview fails?

Confirm both run the same commit. Then compare the build result, Preview variables, backend target, browser request and function logs. The first difference tells you where to look.

Does a green Vercel build prove the feature works?

No. It shows the deployment built. Reproduce the user request on the Preview URL and check runtime and downstream service evidence.

Which Preview URL should I send to a reviewer?

The commit-specific deployment URL, when you're discussing one exact result. A branch URL can move to a newer deployment.

Can I copy production environment variables into Preview to fix it?

Agree the data and credential boundary with the owner first. A Preview should normally use test services and scoped secrets; live credentials can expose production data to test workflows.

More questions and answers →

Sources and further reading