diff --git a/src/Fieldtypes/Bard/LinkMark.php b/src/Fieldtypes/Bard/LinkMark.php index 91f21ec4d2..d5bc90e84b 100644 --- a/src/Fieldtypes/Bard/LinkMark.php +++ b/src/Fieldtypes/Bard/LinkMark.php @@ -65,10 +65,18 @@ protected function convertHref($href) return ''; } - if ($item instanceof Entry) { + if (! $this->isApi() && $item instanceof Entry) { return ($item->in(Site::current()->handle()) ?? $item)->url(); } return $item->url(); } + + private function isApi() + { + $isRestApi = config('statamic.api.enabled', false) && Str::startsWith(request()->path(), config('statamic.api.route', 'api')); + $isGraphqlApi = config('statamic.graphql.enabled', false) && Str::startsWith(request()->path(), 'graphql'); + + return $isRestApi || $isGraphqlApi; + } }