Replies: 5 comments
-
I've played around with server.php but haven't gotten it to work. // https://github.com/laravel/valet/blob/3e5f16fee53db94233d16fd8f9f0e0b17fc98b09/server.php#L113
if ($_SERVER['HTTP_HOST'] === $_SERVER['SERVER_ADDR']) {
$siteName = basename(
explode('/', $_SERVER['REQUEST_URI'])[1] ?? null,
'.'.$valetConfig['tld']
);
$_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], strlen($siteName . '.' . $valetConfig['tld']) + 1);
} else {
$siteName = basename(
// Filter host to support wildcard dns feature
valet_support_wildcard_dns($_SERVER['HTTP_HOST'], $valetConfig),
'.'.$valetConfig['tld']
);
} |
Beta Was this translation helpful? Give feedback.
-
I was having the same problem on a clean install I ran |
Beta Was this translation helpful? Give feedback.
-
This is what I've added to server.php file in /**
* If the HTTP_HOST is an IP address, check the start of the REQUEST_URI for a
* valid hostname, extract and use it as the effective HTTP_HOST in place
* of the IP. It enables the use of Valet in a local network.
*/
if (preg_match('/^([0-9]+\.){3}[0-9]+$/', $_SERVER['HTTP_HOST'])) {
$uri = ltrim($_SERVER['REQUEST_URI'], '/');
if (preg_match('/^[-.0-9a-zA-Z]+\.'. $valetConfig['tld'] .'/', $uri, $matches)) {
$host = $matches[0];
$_SERVER['HTTP_HOST'] = $host;
$_SERVER['REQUEST_URI'] = str_replace($host, '', $uri);
}
} |
Beta Was this translation helpful? Give feedback.
-
There is a pull request from @thinkverse for this that been hanging around for a while - https://github.com/laravel/valet/pull/1284/files |
Beta Was this translation helpful? Give feedback.
-
There can not only be there four of us facing this problem. Has anyone come up with a reliable solution? The code above doesn't work for me. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
When following the steps given here: https://laravel.com/docs/9.x/valet#sharing-sites-on-your-local-network, sharing on my local network still does not work.
Steps To Reproduce:
<title>Valet - Not Found<title>
only containing the words '404 - Not Found' (probably served by function show_valet_404() in server.php).Diagnosis
I think Valet's php script does not understand that URI with the IP address prefix.
Beta Was this translation helpful? Give feedback.
All reactions