env: Add support for dynamic URLs and allow setting WP_HOME and WP_SITEURL via env variables
#71028
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Closes #23947, #65008
Why?
Currently the wp-env site is set to localhost address, so trying to map the site to the likes of an ngrok external domain just results in a redirect back to localhost.(#23947)
This PR adds support for that by dynamically defining the
WP_HOMEandWP_SITEURLvia the snippet sent by @glendaviesnz.Alongside this PR also adds support for setting
WP_HOMEandWP_SITEURLvia env variables to allow for cases where the url is generated dynamically like gitpod.How?
This PR solves this by adding
WP_ENV_DYNAMIC_URLS_ENABLEDenv var ( default to true ) which enables dynamically defining WP_HOME and WP_SITEURL constants.This PR also adds
WP_ENV_HOMEURL,WP_ENV_SITEURLfor development environment andWP_ENV_TESTS_HOMEURL,WP_ENV_TESTS_SITEURLfor tests environment.to disable dynamically defining , pass
WP_ENV_DYNAMIC_URLS_ENABLED=falsewhen running wp-env start.Testing Instructions
_npm run wp-env start -- --updateScreenshots or screencast
npm run wp-env start -- --update
WP_ENV_DYNAMIC_URLS_ENABLED=false npm run wp-env start -- --update
WP_ENV_SITEURL & WP_ENV_HOMEURL support