Voyager: [BUG] Subfolders not included in menu links

Created on 10 Mar 2019  路  8Comments  路  Source: the-control-group/voyager

Version information

  • Laravel: v5.8.3
  • Voyager: v1.2.1
  • PHP: 7.2.11
  • Database: MariaDB 10.3.10

Description

The admin menu has incorrect links when Voyager is accessed in a subdirectory. Routes are correct as they work as expected, so we have correct app urls but incorrect menu links. Note: this procedure is to demonstrate the problem and does not create a secure laravel installation.

Steps To Reproduce

  1. Install Laravel and Voyager in your public_html folder in mylaravelapp subfolder

composer create-project --prefer-dist laravel/laravel mylaravelapp
cd mylaravelapp
composer require tcg/voyager
-- set database options --
php artisan voyager:install
php artisan voyager:admin [email protected] --create

  1. Go to http://localhost/mylaravelapp/public/admin/login
  2. Login using mail/password
  3. Hover the mouse over left menu links or click a link

Links are pointing to http://localhost/admin/* which is wrong. URLs are accessible using http://localhost/mylaravelapp/public/admin/* which is correct.

Expected behavior

Menu's links should be pointing to http://localhost/mylaravelapp/public/admin/* addresses. This works as expected with Laravel 5.7.28 and Voyager 1.1.12.

possible bug

Most helpful comment

The problem is that the menu-item urls are resolved relative, not absolute.
Need to find out if its ok to default to true here:
https://github.com/the-control-group/voyager/blob/4ee291ff24a43a56bec5009601f7ce874b725838/src/Models/MenuItem.php#L35
Before, the url was generated like this:
$url = route('xyz', $parameters, false);
which is not really helpful.

All 8 comments

Laravel shouldn't be installed under public_html for security reasons. A search for "laravel in shared hosting" should provide reasoning and solutions.

Having said that, your APP_URL is likely set wrong. Voyager uses named routes for the default menu items, so it's more likely a misconfiguration in your app than a problem in Voyager.

Hi,

Thanks for pointing out that this is insecure. As I stated above I don't do this in production.

From my experiments APP_URL in .env seems to be correct and doesn't seem to change URLs in any way except for assets (for example images are broken when it's incorrect). Under a clean install environment (necessary changes only to .env file) Voyager 1.1.12 works and 1.2.1 doesn't so I don't know how this can be a configuration issue (in that case I think Voyager 1.1.12 wouldn't work either - except if I'm missing something). If it's not Voyager it may be a dependency. Unfortunately at the moment I'm still too new to Laravel to debug this.

For the time being I'll get around this using a subdomain. However, I do think there's a problem somewhere. If you are certain that this is a config issue feel free to close this issue.

Thanks.

Having the same issue.
Had to move laravel public folder to a subfolder in htdocs (main laravel folder is above htdocs). Menu links are broken due to not reflecting the change. ENV APP_URL was updated, route cache dumped. After adding bread the new menu item does not have subfolder in it.

I'm temporarily making the urls static and changing them all manually.

The problem is that the menu-item urls are resolved relative, not absolute.
Need to find out if its ok to default to true here:
https://github.com/the-control-group/voyager/blob/4ee291ff24a43a56bec5009601f7ce874b725838/src/Models/MenuItem.php#L35
Before, the url was generated like this:
$url = route('xyz', $parameters, false);
which is not really helpful.

@emptynick Good catch!

Should it be implemented next version ?! Ty @emptynick :)

I think so, yes

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

winex01 picture winex01  路  3Comments

popica80 picture popica80  路  3Comments

wp-src picture wp-src  路  3Comments

wislem picture wislem  路  3Comments

duongsieu picture duongsieu  路  3Comments