Skip to content

wp server correct WP_HOME value should be retrieved from $_SERVER HTTP_HOST, not SERVER_NAME #101

@lkraav

Description

@lkraav

Describe the bug

If we run our web server on an alternate port, like 8080, let's say using wp server, then $_SERVER SERVER_NAME will not provide the correct WP_HOME calculation value, but $_SERVER HTTP_HOST does.

print_r( $_SERVER );

Array
(
    ...
    [SERVER_NAME] => localhost
    [SERVER_PORT] => 8080
    [REQUEST_URI] => /
    [HTTP_HOST] => localhost:8080
    [SERVER_ADDR] => 127.0.0.1
    [WP_ENV] => development
    ...
)

Alternatively, $_SERVER SERVER_PORT value maybe also has to be used in WP_HOME auto-calculation.

To Reproduce

  1. Run webserver on a non-standard port, like 8080
  2. Use get_theme_file_uri() to calculate an enqueue asset URL
  3. Watch 404 errors for enqueued assets

Expected behavior
Port value recognized.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions