Skip to content

getAbsoluteUrl not including the host #708

@michaelthedev

Description

@michaelthedev

I use laragon for local development and running
I first noticed something like url('home.test')->getAbsoluteUrl() only returned the path (no scheme, no host)

After trying with request()->getUrl()->getAbsoluteUrl() the scheme showed here, but the host was empty
The above code produced this "https:///_manage/test/"

On inspection, i made this change in Pecee\Http\Request

$this->setHost($this->getHeader('http-host'));

// Check if special IIS header exist, otherwise use default.
$url = $this->getHeader('unencoded-url');
if ($url !== null) {
    $this->setUrl(new Url($url));
} else {
    $this->setUrl(new Url(urldecode((string)$this->getHeader('request-uri'))));
}

$this->url->setHost($this->host); // change: since host has already been set

$this->setContentType((string)$this->getHeader('content-type'));

and everything worked fine for:

var_dump(request()->getUrl()->getAbsoluteUrl());
var_dump(\url()->getAbsoluteUrl());

But url('home.page')->getAbsoluteUrl() still returned only the path (without the host & scheme)

If you could look into this. I can provide more information if you need

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions