Skip to content
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

[BUG] Subfolders not included in menu links #3993

Closed
acicovic opened this issue Mar 10, 2019 · 8 comments · Fixed by #4008
Closed

[BUG] Subfolders not included in menu links #3993

acicovic opened this issue Mar 10, 2019 · 8 comments · Fixed by #4008

Comments

@acicovic
Copy link

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 mail@mail.com --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.

@fletch3555
Copy link
Collaborator

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.

@acicovic
Copy link
Author

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.

@Fenweldryn
Copy link
Contributor

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.

@emptynick
Copy link
Collaborator

emptynick commented Mar 12, 2019

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.

@acicovic
Copy link
Author

@emptynick Good catch!

@silici0
Copy link

silici0 commented Mar 14, 2019

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

@emptynick
Copy link
Collaborator

I think so, yes

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants