Skip to content

chore(repo): allow PORT and UI_PORT overrides for sandbox dev servers#8673

Merged
iagodahlem merged 1 commit into
mainfrom
iago/sandbox-ports
May 27, 2026
Merged

chore(repo): allow PORT and UI_PORT overrides for sandbox dev servers#8673
iagodahlem merged 1 commit into
mainfrom
iago/sandbox-ports

Conversation

@iagodahlem

Copy link
Copy Markdown
Member

Summary

Sandbox dev servers couldn't honor PORT or UI_PORT env overrides because of two coupled gaps:

  • Turbo 2.x strict env mode silently strips env vars not declared in globalEnv / globalPassThroughEnv, so PORT and UI_PORT never reached the package scripts.
  • @clerk/ui's dev:sandbox:serve and the clerk-js sandbox template's uiScriptUrl were hardcoded to localhost:4011.

After this PR:

PORT=4001 UI_PORT=4012 pnpm dev:sandbox

starts clerk-js on 4001 and @clerk/ui on 4012, and the sandbox template loads ui.browser.js from the matching UI_PORT.

PORT and UI_PORT default to their original values when unset, so existing workflows are unchanged.

Test plan

  • pnpm dev:sandbox (no env vars) starts on 4000/4011 as before
  • PORT=4001 UI_PORT=4012 pnpm dev:sandbox starts on 4001/4012, sandbox HTML loads ui.browser.js from 4012
  • CI green

Two coupled issues prevented overriding the sandbox dev server ports:

1. Turbo 2.x runs in strict env mode by default, so env vars not listed
   in globalEnv/globalPassThroughEnv never reach package scripts. PORT
   and UI_PORT were both being filtered out before clerk-js and @clerk/ui
   could see them. Added both to globalPassThroughEnv.

2. The @clerk/ui sandbox serve script and the clerk-js sandbox template's
   uiScriptUrl were both hardcoded to localhost:4011. Parameterized with
   UI_PORT (defaulting to 4011) so PORT/UI_PORT can be set independently
   when running multiple sandboxes in parallel.

After this change:

    PORT=4001 UI_PORT=4012 pnpm dev:sandbox

starts clerk-js on 4001 and @clerk/ui on 4012, with the sandbox template
loading ui.browser.js from the matching UI_PORT.
@changeset-bot

changeset-bot Bot commented May 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0e53798

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented May 27, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment May 27, 2026 7:24pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

Snapi: no API changes detected in @clerk/backend, @clerk/clerk-js, @clerk/nextjs, @clerk/react, @clerk/shared, @clerk/ui.

@pkg-pr-new

pkg-pr-new Bot commented May 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8673

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8673

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8673

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8673

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8673

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8673

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8673

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8673

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8673

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8673

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8673

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8673

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8673

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8673

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8673

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8673

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8673

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8673

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8673

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8673

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8673

commit: 0e53798

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 83f2418d-8f0f-4ef3-b91e-37079797331d

📥 Commits

Reviewing files that changed from the base of the PR and between 0796911 and 0e53798.

📒 Files selected for processing (4)
  • .changeset/sandbox-port-env-vars.md
  • packages/clerk-js/rspack.config.js
  • packages/ui/package.json
  • turbo.json

📝 Walkthrough

Walkthrough

This PR introduces environment variable configurability for the UI port in the sandbox development setup. The turbo.json configuration is updated to pass through PORT and UI_PORT environment variables globally across monorepo tasks. The rspack.config.js build configuration then uses process.env.UI_PORT (defaulting to 4011) instead of a hardcoded port when constructing the UI script URL for the sandbox. Similarly, the dev:sandbox:serve script in packages/ui/package.json is updated to use the configurable UI_PORT environment variable. A changeset file documents this change.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: allowing PORT and UI_PORT environment variable overrides for sandbox dev servers, which is exactly what the changeset accomplishes across turbo.json, rspack.config.js, and package.json.
Description check ✅ Passed The description is well-related to the changeset, clearly explaining the problem (Turbo 2.x strict env mode and hardcoded port values), the solution implemented (adding env vars to globalPassThroughEnv and parameterizing ports), and practical examples of the new functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands and usage tips.

@iagodahlem iagodahlem requested a review from a team May 27, 2026 19:37
@iagodahlem iagodahlem merged commit 425e093 into main May 27, 2026
45 checks passed
@iagodahlem iagodahlem deleted the iago/sandbox-ports branch May 27, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants