Voyage Compass Missing

Solved
kaprinkey1

May 22nd, 2023 04:49 PM

Voyager Compass

I have a quick question. I am altering the wave application to suit my needs such as adding controllers, models, migration files and etc.

For some reason when I start messing with the database, my compass tool in voyager disappears and I've tried my hardest to figure out why but the logs do not show an error when this happens.


I am not sure how this happens. I can upload some of my files if needed. It seems to happen after I run db commands. I also installed laravel scout for search functionality but I don't think Scout would affect that. I am getting a 403 error now when trying to access compass.

403_error.PNG

bobbyiliev

May 23rd, 2023 12:08 AM

Best Answer

Hey there 👋,

Yep, Compass is only available in development mode for security reasons.

If you set the APP_ENV variable in your .env file to local, you will be able to access Compass. Once that env var is set to production, you will no longer be able to access it.

Here is the discussion that covers why this decision was made:

Voyager Compass discussion

kaprinkey1

May 26th, 2023 05:54 PM

Yeah I am in development mode and working remotely on my dedicated server. I just changed it to local and still get the 403 forbidden error. I forgot to mention last time that it also disappears from the menu but weirdly i can still voyager commands in the code like this one

@if(Voyager::image(theme('logo')))
                        <img class="h-9" src="{{ Voyager::image(theme('logo')) }}" alt="Company name">
                    @else
                        <svg class="w-9 h-9" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 208 206"><defs/><defs><linearGradient id="a" x1="100%" x2="0%" y1="45.596%" y2="45.596%"><stop offset="0%" stop-color="#5D63FB"/><stop offset="100%" stop-color="#0769FF"/></linearGradient><linearGradient id="b" x1="50%" x2="50%" y1="0%" y2="100%"><stop offset="0%" stop-color="#39BEFF"/><stop offset="100%" stop-color="#0769FF"/></linearGradient><linearGradient id="c" x1="0%" x2="99.521%" y1="50%" y2="50%"><stop offset="0%" stop-color="#38BCFF"/><stop offset="99.931%" stop-color="#91D8FF"/></linearGradient></defs><g fill="none" fill-rule="evenodd"><path fill="url(#a)" d="M185.302 38c14.734 18.317 22.742 41.087 22.698 64.545C208 159.68 161.43 206 103.986 206c-39.959-.01-76.38-22.79-93.702-58.605C-7.04 111.58-2.203 69.061 22.727 38a104.657 104.657 0 00-9.283 43.352c0 54.239 40.55 98.206 90.57 98.206 50.021 0 90.571-43.973 90.571-98.206A104.657 104.657 0 00185.302 38z"/><path fill="url(#b)" d="M105.11 0A84.144 84.144 0 01152 14.21C119.312-.651 80.806 8.94 58.7 37.45c-22.105 28.51-22.105 68.58 0 97.09 22.106 28.51 60.612 38.101 93.3 23.239-30.384 20.26-70.158 18.753-98.954-3.75-28.797-22.504-40.24-61.021-28.47-95.829C36.346 23.392 68.723.002 105.127.006L105.11 0z"/><path fill="url(#c)" d="M118.98 13c36.39-.004 66.531 28.98 68.875 66.234 2.343 37.253-23.915 69.971-60.006 74.766 29.604-8.654 48.403-38.434 43.99-69.685-4.413-31.25-30.678-54.333-61.459-54.014-30.78.32-56.584 23.944-60.38 55.28v-1.777C49.99 44.714 80.872 13.016 118.98 13z"/></g></svg>
                    @endif

Now if I were to save my added files and reinstall wave, compass is there but the moment i start adding my own stuff it goes away. I plan to pinpoint exactly when this happens after I push all of my code live which will be in a few weeks.

Honestly, I know the cli commands so I do not and have not really used compass but wanted to bring it to your attention if someone else had not.

I truly appreciate the effort put into this and is why I got devdojo pro because I knew this wouldn't be just given up on like so many other great projects out there.

bobbyiliev

May 27th, 2023 10:34 AM

Hi there,

This is quite interesting, once you've changed the APP_ENV to local, you might need to run php artisan config:clear to reflect that new change.

Let me know how it goes!

kaprinkey1

May 27th, 2023 03:05 PM

Hey Bobby.

I ran the artisan command and it still gives me this error. I attached a screenshot.

403forbidden.PNG

bobbyiliev

May 28th, 2023 09:40 AM

Hi there,

This is where the check happens in the controller:

VoyagerCompassController.php#L19-L26

The two checks that happen are:

  • Check permission:

        $this->authorize('browse_compass');
    
  • Check if app is not local and compass is not enabled for production (which is not recommended)

        if (!\App::environment('local') && !config('voyager.compass_in_production', false)) {
            throw new AccessDeniedHttpException();
        }
    

As long as your user has a role that has the browse_compass privileges, and your environment is set to local, then it should all be working as expected.

If you change the app env to anything rather than local, and then run php artisan optimize or php artisan config:cache then the value will be cached and you will need to run php artisan optimize:clear or php artisan config:clear to clear the env variables from your cache.

There isn't anywhere in the Voyager logic that the AccessDeniedHttpException class is used.

Let me know how it goes!

kaprinkey1

May 28th, 2023 12:17 PM

I figured out the issue. My vendor folder in phpstorm had not been added to the project for some reason. The moment I added the folders back to the project Compass appeared after restarting the server.

I know this because when I went to alter the compasscontroller it told me it was read only and not part of the project.

kaprinkey1

May 28th, 2023 12:25 PM

Thank you for the assistance and guidance. I was wondering why it was there and then disappeared lol.

I thought about removing the auth needed to access compass as I dont need the user function but if I do that anybody can access the /admin/compass url and take actions.

I am using wave for an advertiser publishing site. I thought about using a CMS but I want total control over the files and content. Notonly that but I don't want the security vulnerabilites that come with plugins and extensions.

Report
1
kaprinkey1

May 28th, 2023 11:08 PM

Oh I forgot to tell y'all this sooner but the eBooks page, when you click the pdf option, it doesn't load the page and simply has the spin icon.

On a cellphone or tablet it is even harder to get it. I have to hit the back button to get the download to start.

Report
1
bobbyiliev

May 28th, 2023 11:43 PM

No problem at all! Happy to hear that you've got it all working! It is possible that the web server restart actually helped to clear the cache as well.

Ah, thank you for reporting that eBooks problem! I'll look into this today!

bobbyiliev

May 29th, 2023 12:23 AM

The eBook download button should now be fixed! Let me know if anything else pops up!

kaprinkey1

May 29th, 2023 12:55 AM

See I knew it was something small or stupid lol. Yes it is working, thank you. It will make downloading it onto my iPad a breeze now!

I noticed that Tony really likes to use SVG images and I can see why. I am still learning the SVG ropes but it is much better than using a regular image. Hence the name lol. I actually was able to use the voyager back end icons on the front end with a bit of svg magic

lol.

Thanks again.

Report
1
bobbyiliev

May 29th, 2023 01:06 AM

Nice! That sounds very cool! Feel free to write a blog post about it if you have the time! I saw that you posted your first blog post a few weeks ago!

Btw, just tested the download button on my phone, it looks like that Safari is downloading the file as .HTML which does not seem to work, however it works when using Chrome. So on your iPad you could use Chrome to download the PDF and then you will be able to import it to the Books app!

I'll have to look into why Safari on mobile does that :D

kaprinkey1

May 29th, 2023 01:54 PM

Yes, when I did that, I thought I was posting to the blog you can create in devdojo but it actually posted to the blog on devdojo lol. I plan to make a post today. I actually use chatgpt to convert images into svg and to get svg files needed. Its much easier than finding and using a website to do it.

Some may see it as a shortcut or cop-out but I see it as an advantage over those who do not use it. Laravel Wave is open source, meaning ChatGPT most likely has evaluated the repo on github considering github allowed it lol.

kaprinkey1

May 29th, 2023 02:13 PM

I do have a question for you. I know Voyager has a menu builder and what not. However, whenever I build a menu and try to render it on the front end, for some reason, I cannot get it to render?

I figured I am doing something wrong? I am still learning Laravel. I switched from WordPress which is entirely different lol.

Actually I just thought of this and edited this question, could the missing vendor folder play a role in the menus appearing?

Load More Answers