Skip to content

Replace hardcoded port 3000 with dynamic port in dev URLs#110002

Open
p-jackson wants to merge 2 commits intodot-env-portfrom
dot-env-port-dynamic-port
Open

Replace hardcoded port 3000 with dynamic port in dev URLs#110002
p-jackson wants to merge 2 commits intodot-env-portfrom
dot-env-port-dynamic-port

Conversation

@p-jackson
Copy link
Copy Markdown
Member

Part of #109963

Proposed Changes

  • Add {{key}} template support to config values in create-calypso-config, resolved at config creation time
  • Config JSON files (development.json, dashboard-development.json) use {{port}} in URL values (wpcom_url, logout_url) so they reflect the actual server port
  • Client code uses config('port') for dev URLs in dashboard routing, jetpack-connect, and checkout
  • CORS allowlists in wpcom-proxy-request and calypso-url match localhost origins on any port by stripping the port and comparing against known dev origins
  • Export resolveTemplates from create-calypso-config for server-side use on clientData (which must remain a plain object)

Why are these changes being made?

When running Calypso on a non-default port (e.g. via PORT=4321 or cmux/conductor), many URLs were hardcoded to :3000 — the Reader link in the masterbar, dashboard cross-origin links, CORS allowlists, etc. This makes the port fully dynamic so all dev URLs match the actual server port.

Testing Instructions

  • Run PORT=4321 yarn start (or any non-3000 port)
  • Verify the Reader link in the masterbar points to :4321
  • Verify window.configData.wpcom_url contains the correct port
  • Verify no :3000 appears in the HTML source: curl -s http://calypso.localhost:4321 | grep -c ':3000' should be 0
  • Verify dashboard links work on http://my.localhost:4321

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you tested accessibility for your changes? Ensure the feature remains usable with various user agents (e.g., browsers), interfaces (e.g., keyboard navigation), and assistive technologies (e.g., screen readers) (PCYsg-S3g-p2).
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@matticbot
Copy link
Copy Markdown
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • agents-manager
  • blaze-dashboard
  • happy-blocks
  • help-center
  • notifications
  • odyssey-stats
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug dot-env-port-dynamic-port on your sandbox.

@p-jackson p-jackson self-assigned this Apr 15, 2026
Add {{key}} template support to config values, resolved at config
creation time via create-calypso-config. Config JSON files use
{{port}} in URL values so they reflect the actual server port.

Client code uses config('port') for dev URLs in dashboard routing,
jetpack-connect, and checkout. CORS allowlists in wpcom-proxy-request
and calypso-url match localhost origins on any port.
@p-jackson p-jackson force-pushed the dot-env-port-dynamic-port branch from 8ce6fe7 to 21bebd9 Compare April 15, 2026 13:06
@p-jackson p-jackson changed the base branch from dot-env-port-cmux-conductor to dot-env-port April 15, 2026 13:07
@p-jackson p-jackson marked this pull request as ready for review April 15, 2026 13:09
@p-jackson p-jackson requested a review from a team as a code owner April 15, 2026 13:10
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants