getkirby-v2 / toolkit

This is the deprecated toolkit for Kirby v2.
http://getkirby.com
81 stars 50 forks source link

Wrong URL when tunnelling localhost #157

Closed pedroborges closed 4 years ago

pedroborges commented 8 years ago

With ngrok (there are other services alike) I can share a local port with a client using a URL it provides, for example:

http://b183e8fd.ngrok.io -> localhost:8000

Kirby uses only localhost:8000 to generate all URLs, not b183e8fd.ngrok.io. I can get Kirby to use the right URL by changing line 321 of lib/url.php:

// from:
return static::scheme() . '://' . server::get('SERVER_NAME', server::get('SERVER_ADDR')) . r($port, ':' . $port);
// to
return static::scheme() . '://' . server::get('HTTP_HOST', server::get('SERVER_ADDR'));

Is this something that can be fixed without messing with another use cases I'm not aware of?

jaceq commented 7 years ago

Hi, I have same issue, this is true whenever kirby is behind some proxy and runs on non standard port (not 80 and 443)... There should be a config option disabling port in $url (it seems like a if or 2 to achieve that)

Pascalmh commented 7 years ago

@jaceq https://github.com/getkirby/kirby/issues/255 this seems to be a good workaround for now.