Skip to content

Incorrect $_SERVER HTTP_HOST #815

Description

@svandragt

$_SERVER['HTTP_HOST'] = getenv( 'COMPOSE_PROJECT_NAME' ) . '.' . getenv( 'COMPOSE_PROJECT_TLD' );

The HTTP_HOST is set to the COMPOSE_PROJECT_NAME followed by a dot/period followed by the COMPOSE_PROJECT_TLD.

In the two most recent projects I've been working on, the COMPOSE_PROJECT_TLD has been empty, which causes problems for the $_SERVER['HTTP_HOST'] and the DOMAIN_CURRENT_SITE. This in turn affects wp-cli commands without a URL to fail.

I solved this locally by adding the following correction to the .config/load.php file:

if ( ! defined( 'DOMAIN_CURRENT_SITE' ) ) {
	$_SERVER['HTTP_HOST'] =  rtrim( $_SERVER['HTTP_HOST'], '.' );
	define( 'DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST'] );
}

It would be good to fix upstream. I'm unsure why COMPOSE_PROJECT_TLD is not set, this is possibly the root bug. If it follows the expected altis.dev then the project name should be updated.

The docker readme here says:

If you wish to re-use this configuration, you'll need to use the COMPOSE_PROJECT_NAME environment variable to change the name of the containers and local domain, otherwise there will be conflicts.

So it seems there is some hidden knowledge around the TLD not expected to have anything in it as the project name would already contain the local tld.

Verify the bug:

$ wp site list
Error: Site 'myproject.altis.dev.' not found. Verify DOMAIN_CURRENT_SITE matches an existing site or use `--url=<url>` to override.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions