HansSchouten / Laravel-Pagebuilder

A drag and drop pagebuilder to manage pages in any Laravel project
https://www.phpagebuilder.com
MIT License
799 stars 184 forks source link

Demo Installation on Laravel Valet issue #61

Open jcargilo opened 3 years ago

jcargilo commented 3 years ago

This is more of a documentation suggestion as I just ran across this while attempting to try out this promising package.

I followed the instructions on the documentation to setup the demo, but was getting a blank page instead of the welcome page, and then when I went to /admin, I was getting the welcome page instead of the login page.

Backing through the route to the helpers file, I realized that under the phpb_current_full_url() method, the helpers utilizes the $_SERVER['SERVER_NAME'] to obtain the domain for the current site.

Laravel Valet Issue #411 which, although from 2017, is still relevant on the most current version of Laravel Valet indicates that the $_SERVER['SERVER_NAME'] is empty in standard non-secure situations. One workaround was to make the site secure, which causes Laravel Valet to generate the appropriate NGINX file which sets that value. Once I did that AND updated the .env APP_URL value to include the S, the welcome/login pages appeared as expected.

It might be a good idea to save others the time to handle this, since it's a Laravel solution and Valet is super common, by adding a note to the documentation. If nothing else, this will be in the issues area so others can see my above workaround.

HansSchouten commented 3 years ago

Thanks for the heads up! I am not using Valet so I would not have encountered this issue myself. I will refer to this in the readme.

One workaround was to make the site secure

What did you exactly change to make this work?

jcargilo commented 3 years ago

For clarity, here's my setup:

Laravel Valet is parked in my ~/code directory so it will serve up any sites found within the first level of directories.

Code
  Laravel-PageBuilder
    app/
    ...
    public/
    composer.json
    ...

This resolves my local site automagically to http://laravel-pagebuilder.test.

Due to the issue I mentioned previously, to get Laravel Valet to set the $_SERVER['SERVER_NAME'] value in the appropriate NGINX file, the workaround is to secure the site. For me, I did the following from my project root (~/Code/Laravel-PageBuilder/) directory:

laravel valet secure

Valet basically creates a certificate, updates the NGINX configuration (including setting $_SERVER['SERVER_NAME']), and then restarts NGINX.

At this point, the routing worked as intended. Hope that's helpful!

Shigeki1120 commented 3 years ago

@jcargilo thanks a lot. I was at a complete loss