Skip to content

wp-env: Support for WP_SITEURL and WP_HOME without automatically appending port number #69776

Open

Description

@eliot-akira

What problem does this address?

I'm setting up a local dev site with HTTPS using NGINX and a self-signed certificate (mkcert).

In .wp-env.json I have defined the constants:

{
  "config": {
    "WP_SITEURL": "https://wp.local",
    "WP_HOME": "https://wp.local"
  }  
}

However wp-env automatically adds a port number to the URL. The site still works but static assets like CSS & JS are not loaded. It can be fixed by editing ~/wp-env/UNIQUE_HASH/wp-config.php.

define( 'WP_SITEURL', 'https://wp.local:3333' );
define( 'WP_HOME', 'https://wp.local:3333' );

It would be helpful if wp-env supported an option to not append a port number to the local site URL.

What is your proposed solution?

A new option to disable appending port number to the site URL. Or maybe when the site URL ends with a trailing slash, it would be kept as is.

Activity

  1. getsource commented on Aug 7, 2025

    @getsource
    Member

    Thanks @eliot-akira for the issue and @Sukhendu2002 for the PR!

    I chatted a bit with @Sukhendu2002 about this issue.

    I like the idea of doing this without adding a new option, if it's possible --
    whether through the existing port number option, or a slash (as @eliot-akira mentioned) if that doesn't add additional issues.

  2. eliot-akira commented on Aug 20, 2025

    @eliot-akira
    Author

    doing this without adding a new option

    From the two proposed solutions, I like the idea of using the existing option port. There's also the env variable WP_ENV_PORT which overrides it. Setting it to an empty string sounds appropriate, but that might not be distinguishable from it being undefined. The option is documented as an integer, so maybe 0 (zero) would work..? Or false (string or boolean).

    With the other idea of using a slash, there may be people who unknowingly have a trailing slash in their site URL, that wp-env might be trimming before adding the port number.

    ..Mm, both options seem a bit ambiguous and "implicit" behavior. It's not so clear what they're doing, to disable automatically appending the port number to the site URL.

    It seems the most straight-forward implementation would be a new option preserveSiteUrl or keepSiteUrl (easier to spell/type). Or the opposite, appendSiteUrlPortNumber which is true by default. Then the config property can be readable and explains what it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions