Skip to content

Commit 04d1416

Browse files
committed
Replace base URL in request method
1 parent 723f6ad commit 04d1416

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Clients/SiteHttpClient.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ public function __construct(Site $site, HttpHandlerInterface $handler = null)
3939
$this->setThrowExceptions(true);
4040
}
4141

42+
/**
43+
* If given a URL containing the siteBaseUrl, remove it.
44+
*
45+
* @inheritdoc
46+
*/
47+
public function createRequest(string $method, string $uri, $body, array $headers = [], array $options = []): \Garden\Http\HttpRequest {
48+
// Replace the base url (it will get re-appended). The URL may have been on the site directly, but we actually want to use the configured internal URL.
49+
$uri = str_replace($this->site->getBaseUrl(), "", $uri);
50+
return parent::createRequest($method, $uri, $body, $headers, $options);
51+
}
52+
4253
/**
4354
* Get a copy of the client.
4455
* This copy will use an access token to communicate with the site as the System user.

0 commit comments

Comments
 (0)