Skip to content

Use app url#1212

Merged
priosshrsth merged 2 commits intofeature/c1-optimizationfrom
use-app-url
May 8, 2026
Merged

Use app url#1212
priosshrsth merged 2 commits intofeature/c1-optimizationfrom
use-app-url

Conversation

@priosshrsth
Copy link
Copy Markdown
Collaborator

Changes

  • It just uses vercel branch url for preview deployments

@priosshrsth priosshrsth self-assigned this May 8, 2026
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tasks-app Ready Ready Preview, Comment May 8, 2026 11:46am

Request Review

@priosshrsth priosshrsth changed the base branch from main to feature/c1-optimization May 8, 2026 11:32
@priosshrsth priosshrsth marked this pull request as ready for review May 8, 2026 11:44
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 8, 2026

Deployment failed with the following error:

Deploying Serverless Functions to multiple regions is restricted to the Pro and Enterprise plans.

Learn More: https://vercel.link/multiple-function-regions

@priosshrsth priosshrsth merged commit cf27517 into feature/c1-optimization May 8, 2026
3 of 4 checks passed
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 8, 2026

Greptile Summary

This PR refactors apiUrl resolution into a getAppUrl() function that prefers VERCEL_BRANCH_URL (a stable, per-branch URL) over VERCEL_URL (a per-deployment URL) for non-production Vercel environments, making the app URL consistent across re-deployments on the same branch.

  • New branch URL preference: For any non-production deployment, if VERCEL_BRANCH_URL is set it is used instead of VERCEL_URL; production still uses VERCEL_PROJECT_PRODUCTION_URL.
  • Dead-code guard: A startsWith('http') check on VERCEL_URL is unreachable in practice because Vercel never includes a protocol prefix in that variable; it can be removed to avoid misleading future readers.

Confidence Score: 4/5

Safe to merge — the core logic change (preferring VERCEL_BRANCH_URL) is correct and intentional; only a dead-code guard warrants cleanup.

The production path is unchanged. The branch-URL preference is straightforward and the fallback chain to VERCEL_URL preserves previous behaviour when VERCEL_BRANCH_URL is absent. The only issue is an unreachable startsWith('http') guard that adds confusion but causes no runtime defect.

src/config/index.ts — specifically the startsWith('http') guard added in getAppUrl().

Important Files Changed

Filename Overview
src/config/index.ts Refactors URL resolution into getAppUrl() to prefer VERCEL_BRANCH_URL (stable branch URL) over VERCEL_URL (deployment-unique URL) for non-production environments; includes a dead-code path for URLs already prefixed with http.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[getAppUrl called] --> B{VERCEL_ENV === 'production'?}
    B -- Yes --> C[return https:// + VERCEL_PROJECT_PRODUCTION_URL]
    B -- No --> D{VERCEL_BRANCH_URL set?}
    D -- Yes --> E[return https:// + VERCEL_BRANCH_URL]
    D -- No --> F{VERCEL_URL starts with 'http'?}
    F -- Yes --> G[return VERCEL_URL as-is - dead code: Vercel never sets protocol prefix]
    F -- No --> H{preview or staging?}
    H -- Yes --> I[return https:// + VERCEL_URL]
    H -- No --> J[return http:// + VERCEL_URL]
Loading

Reviews (1): Last reviewed commit: "Merge branch 'feature/c1-optimization' i..." | Re-trigger Greptile

Comment thread src/config/index.ts
Comment on lines +15 to +20
const url = process.env.VERCEL_URL
if (url && url.startsWith('http')) {
return url
}

const isVercelDeployment = vercelEnv === 'preview' || vercelEnv === 'staging'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The startsWith('http') branch is effectively dead code. Vercel's VERCEL_URL is documented to contain only the hostname (e.g. my-app-abc123.vercel.app) — never a protocol-prefixed URL — so this condition will never be true in any Vercel environment. Leaving it in can mislead future readers into thinking VERCEL_URL might carry a protocol, and it silently skips the https/http selection logic even if a misconfigured value were passed. The guard can be removed safely.

Suggested change
const url = process.env.VERCEL_URL
if (url && url.startsWith('http')) {
return url
}
const isVercelDeployment = vercelEnv === 'preview' || vercelEnv === 'staging'
const url = process.env.VERCEL_URL
const isVercelDeployment = vercelEnv === 'preview' || vercelEnv === 'staging'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants