Open lkraav opened 5 years ago
Even this is true in some cases, the value of $_SERVER
widely change depending on the web-server, proxy, etc. So no auto-calculation is really trustable.
Moreover, $_SERVER
values that start with HTTP_
can be overridden via headers, meaning that a client can override those (and that could have security implications).
This is why it is usually preferred to avoid them, and rely on values like SERVER_NAME
that depends on server configuration.
This is also why is highly suggested to manually set WP_HOME
: auto-calculation is not really trustable here.
That said, looking at SERVER_PORT
is something we could do, because it is little effort and can be useful.
I agree, patching SERVER_PORT
is probably the way to go here.
This issue stems a bit from https://github.com/wecodemore/wpstarter/issues/100
We could configure our local staging port values dynamically via something like wp server --port 8081
, without needing to mod the committed .env
template. It's nearly the only thing we need to mod.
Please check if 4c76d9d solved it. Thanks.
Please check if 4c76d9d solved it. Thanks.
I tested with latest dev build today, and something is still going wrong. Without explicitly setting WP_HOME
, a ton of errors are output:
Notice: Undefined index: host in wpstarter.git/vendor/wp-cli/server-command/router.php on line 77
I'm serving with wp server --docroot=public
.
@lkraav, I think you have to pass the URL to WP CL with the --url
parameter.
WP Starter is designed to guess the URL in a web server environment.
When you're on CLI, $_SERVER
only contains env variables, nothing that can help WP Starter determine the URL correctly.
The best thing you can do is tell WP CLI which URL you want to "emulate".
Can I close this?
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 correctWP_HOME
calculation value, but$_SERVER HTTP_HOST
does.Alternatively,
$_SERVER SERVER_PORT
value maybe also has to be used inWP_HOME
auto-calculation.To Reproduce
get_theme_file_uri()
to calculate an enqueue asset URLExpected behavior Port value recognized.