Skip to content

CLI: Fix --login option and "landingPage" Blueprint property #2344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 22, 2025

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Jul 9, 2025

Makes the --login flag work in Playground CLI.

When you start the CLI server for the second time on the same machine it shows the login screen instead of auto-logging you in. The culprit is the playground_auto_login_already_happened cookie, which the first run sets and later runs inherit. Because the cookie survives process restarts, the auto-login plugin silently skips its job. 

Solution

run-cli.ts now tracks whether a request is the very first one served by the process. On that first hit it:
• clears the stale cookie by returning a Set-Cookie header that expires it immediately, and
• responds with a 302 pointing to /, guaranteeing the request that follows will hit WordPress after the login routine runs.

The logic is guarded by a boolean isFirstRequest flag initialised at boot and flipped after the first response.

As a follow up, we'll need to also adjust how the landingPage property is handled (it collides with the hardcoded redirection to /)

CI adjustments

Because the very first HTTP call now yields a redirect, the workflow had to be taught to trigger—and then ignore—the 301/302 chain. The fix:
• primes the server with an initial curl so the redirect is consumed before the readiness probe starts
• replaces the Playground-CLI-based package host with a Python http.server to avoid using tool that's being tested in the test

How to verify

Run wp-playground server twice in a row. Each session should open directly in wp-admin without showing the login form. The CI matrix stays green.

@adamziel adamziel requested a review from brandonpayton July 9, 2025 22:00
@adamziel adamziel added [Type] Bug An existing feature does not function as intended [Package][@wp-playground] CLI labels Jul 9, 2025
@adamziel adamziel force-pushed the fix-login-landing-page-in-cli branch from 3dc7090 to 6aa9cd7 Compare July 22, 2025 12:05
@adamziel adamziel marked this pull request as ready for review July 22, 2025 20:20
@adamziel adamziel merged commit affe728 into trunk Jul 22, 2025
24 of 25 checks passed
@adamziel adamziel deleted the fix-login-landing-page-in-cli branch July 22, 2025 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package][@wp-playground] CLI [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant