Skip to content

Update JavascriptRenderer.php#1555

Closed
marcuschristiansen wants to merge 1 commit intofruitcake:masterfrom
marcuschristiansen:patch-1
Closed

Update JavascriptRenderer.php#1555
marcuschristiansen wants to merge 1 commit intofruitcake:masterfrom
marcuschristiansen:patch-1

Conversation

@marcuschristiansen
Copy link

Update the preg_replace() functions for $cssRoute and $jsRoute to remove the site domain when fetching those assets.

I had issues with the following tags.

<link rel="stylesheet" type="text/css" property="stylesheet" href="//my-domain.com/_debugbar/assets/stylesheets?v=1709304073&amp;theme=dark" data-turbolinks-eval="false" data-turbo-eval="false">

<script src="//my-domain.com/_debugbar/assets/javascript?v=1709304073" data-turbolinks-eval="false" data-turbo-eval="false"></script>

which resulted in 404 errors. Changing the preg_replace regex pattern fixed this for me.

<link rel="stylesheet" type="text/css" property="stylesheet" href="/_debugbar/assets/stylesheets?v=1709304073&amp;theme=dark" data-turbolinks-eval="false" data-turbo-eval="false">

<script src="/_debugbar/assets/javascript?v=1709304073" data-turbolinks-eval="false" data-turbo-eval="false"></script>

Would highly appreciate some input whether this is a feasible fix or if it would break other functionality.

Update the preg_replace functions for $cssRoute and $jsRoute to remove the site domain when fetching those assets.
@josevv28
Copy link

This could fix #1575

@lepusD
Copy link

lepusD commented Mar 24, 2024

I'm on Laravel 10 and I've spent hours trying to get the debugbar to work on localhost with WampServer without running 'artisan serve' and finally found this series of threads so I thank you all as it pointed me in the right direction. I have a custom URL for my localhost set up and for me concatinating the 'APP_URL' environment variable into the file path in 'JavascriptRenderer.php' as follows has worked so far.

$html = "<link rel='stylesheet' type='text/css' property='stylesheet' href='" . env('APP_URL') . "{$cssRoute}' data-turbolinks-eval='false' data-turbo-eval='false'>";

$html .= "<script{$nonce} src='" . env('APP_URL') . "{$jsRoute}' data-turbolinks-eval='false' data-turbo-eval='false'></script>";

@barryvdh
Copy link
Member

barryvdh commented Jan 2, 2026

Is this fixed then? Or still an issue?>

@lepusD
Copy link

lepusD commented Jan 2, 2026

To the best of my knowledge it's no longer an issue. I've had no need to customise any code in Laravel 11 & 12 to get the debugbar working immediately after the composer install.

The original code that was causing me an issue was:

$cssRoute = route('debugbar.assets.css', [
'v' => $this->getModifiedTime('css'),
'theme' => config('debugbar.theme', 'auto'),
], false);

This then became the following in later versions.:

$cssRoute = preg_replace('/\Ahttps?://[^\/]+/', '', route('debugbar.assets.css', [
'v' => $this->getModifiedTime('css'),
'theme' => config('debugbar.theme', 'auto'),
]));

This was also the same for the $jsRoute it should be noted.

Happy New Year!

@barryvdh
Copy link
Member

We moves the rendering to php-debugbar. But not sure why any of these changes would be required otherwise.

@barryvdh barryvdh closed this Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants