-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APP_URL is ignored and assets (stylesheets and javascript) are not loading #1575
Comments
The normal thing is to configure a virtual host to avoid these kind problems <VirtualHost *:8900>
DocumentRoot "C:\laravel\testl\public"
ServerName laravel.localhost
Header set Access-Control-Allow-Credential true
<Directory "C:\laravel\testl\public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost> So, your url is like |
I agree... using a vhost and pointing some fake domain to it in the /etc/hosts file would have been easy, but due to some circumstances outside my control, my current setup is locked down and I can't do that. For now I downgraded to version 3.10, which loads the debug bar's assets correctly regardless of url. |
Same problem from me, when I upgrade to Laravel 11. The "normal thing" with a virtual host is not a solution, when you have (per exemple) multiples apps laravel on the same server (like testing git branchs individually from a test server) . |
Same issue here still on Laravel 10.x (latest 10.x so far). It seems to be due to #1562 which forces relative URLs somehow? I'm not sure. FWIW, my laravel app/website is on a subdirectory on the apache server, and In fact, the routes get correctly set up for the proper subdirectory if I try going to the javascript one manually in the browser, for instance, but it's the injected html to load js/css that's missing the app_url part. |
Something like this in JavascriptRenderer.php should solve the issue: $cssRoute = route('debugbar.assets.css', [
'v' => $this->getModifiedTime('css'),
'theme' => config('debugbar.theme', 'auto'),
]);
$jsRoute = route('debugbar.assets.js', [
'v' => $this->getModifiedTime('js')
]);
$cssRoute = parse_url($cssRoute, PHP_URL_PATH);
$jsRoute = parse_url($jsRoute, PHP_URL_PATH); The issue started when someone requested that the domain name part be removed in addition to the http/https part. I think it's better to just build the complete url and remove the http/https + domain parts, keeping the whole relative path. This should make it work regardless if laravel is hosted in some subdirectory or not. Setting $absolute to false in the "route" helper cuts too deep - it removes the whole APP_URL string. |
Thanks @alexmocanu |
|
Has this been patched? |
Can you try dev-master? |
@barryvdh working like a charm. Thank you! |
@barryvdh dev-master works for me as well. (laravel 11) |
I've managed to reproduce this on a fresh laravel 11 install:
Installed Laravel 11:
composer create-project laravel/laravel:^11.0
In .env i've set the following:
APP_DEBUG=true
APP_URL=http://localhost:8900/testl/public --- my local server runs on port 8900 and I installed laravel in /testl
I installed the debug bar:
composer require barryvdh/laravel-debugbar --dev
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
The debug bar is ignoring the APP_URL variable and assets are not loading (it tries to load them from the root):
Screenshot:
Composer and env files (had to use the txt extension - github won't let me upload them otherwise):
env.txt
composer.json
composer.lock.txt
The issue started appearing with v3.11.0. Installing v3.10 fixes the problem for me
The text was updated successfully, but these errors were encountered: