Skip to content

Commit 8e69802

Browse files
committed
Use the base site URL for action URLs on console requests
1 parent d6ae6de commit 8e69802

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes for Craft CMS 4
22

3+
## Unreleased
4+
5+
- `craft\helpers\UrlHelper::actionUrl()` now returns URLs based on the primary site’s base URL (if it has one), for console requests if the `@web` alias wasn’t explicitly defined.
6+
37
## 4.10.5 - 2024-07-11
48

59
> [!NOTE]

src/helpers/UrlHelper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,10 @@ private static function _createUrl(
633633
}
634634

635635
if ($useRequestHostInfo) {
636-
$baseUrl = Craft::getAlias('@web');
636+
$baseUrl = $request->getIsConsoleRequest() && $request->isWebAliasSetDynamically
637+
// @web is totally unreliable, so go with the base site URL if possible
638+
? static::baseSiteUrl()
639+
: Craft::getAlias('@web');
637640
} elseif ($showScriptName) {
638641
$baseUrl = $request->getIsConsoleRequest() ? '/' : static::host();
639642
} elseif ($cpUrl) {

0 commit comments

Comments
 (0)