Skip to content
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

Support configuring WP_HOME with alternate port #26481

Closed
joemcgill opened this issue Oct 26, 2020 · 4 comments · Fixed by #26507
Closed

Support configuring WP_HOME with alternate port #26481

joemcgill opened this issue Oct 26, 2020 · 4 comments · Fixed by #26507
Labels
[Tool] Env /packages/env

Comments

@joemcgill
Copy link
Member

Is your feature request related to a problem? Please describe.
I want to use @wordpress/env to create an environment to test a headless WordPress application where the front end will be run from a node application running outside of the Env's docker setup. To do this, I want to be able to specify a WP_HOME like http://localhost:3001 in my .wp-env.json file and have the port specified be respected.

However, right now the withOverrides() function in config/config.js overrides the port with the port of the environment specified.

Describe the solution you'd like
I'd like to see withOverrides() check to see if a port value is set for WP_HOME before overriding it here: https://github.com/WordPress/gutenberg/blob/master/packages/env/lib/config/config.js#L262 I think overriding the WP_TESTS_DOMAIN and WP_SITEURL probably makes sense to leave as is.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

@TimothyBJacobs TimothyBJacobs added the [Tool] Env /packages/env label Oct 26, 2020
@noahtallen
Copy link
Member

@joemcgill I'm not super familiar with how these settings are often used. I coded them to be the same because I had some trouble when they were different :) Is there a reason why using the same port for each of these URLs won't work?

What kind of use case would this enable, out of curiosity?

@joemcgill
Copy link
Member Author

joemcgill commented Oct 27, 2020

Hi @noahtallen, like I described in the issue description, I'm wanting to use wp-env run the backend for a headless site where WP_HOME points to a separate node application. Right now, if I have a headless front end running on a different port than the WP container and attempt to set WP_HOME to that application (i.e., the front end should be localhost:3030 and wp-env is on localhost:8888) then this function strips off the port that I supplied in my .wp-env.json file and replaces it with the port for the WP container (i.e. 8888).

@joemcgill
Copy link
Member Author

I put together a PR that I think takes care of this, but I may be missing something so would appreciate feedback!

@noahtallen
Copy link
Member

Interesting use case! Thanks for clarifying, I appreciate understanding that better. I'll take a look at your PR now :)

joemcgill added a commit to joemcgill/gutenberg that referenced this issue Nov 3, 2020
This checks for whether a custom port has been set for `WP_HOME` in the .wp-env.json file before appending the environment's to support local environments where the front end needs to be pointed at another port (e.g., a headless app).

Adds unit test.

Resolves WordPress#26481
noahtallen pushed a commit that referenced this issue Nov 3, 2020
This checks for whether a custom port has been set for `WP_HOME` in the .wp-env.json file before appending the environment's to support local environments where the front end needs to be pointed at another port (e.g., a headless app).

Resolves #26481
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] Env /packages/env
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@joemcgill @TimothyBJacobs @noahtallen and others