Application Homepage error on Login #1672

Closed
opened 2026-02-05 01:34:02 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @ShowMeIT on GitHub (Apr 22, 2020).

Describe the bug
Logging into any account (including admin account) shows a 'page not found error' at the top of the application homepage which it is currently set to show shelves (image attached). if you click 'return to home' or the bookstack logo in header, the page displays correctly.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Enter email & password at login screen
  2. Click on 'login'
  3. See error

Expected behavior
on login i would expect it to see the shelves

Screenshots
If applicable, add screenshots to help explain your problem.

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings):BookStack v0.28.3
  • PHP Version: 7.3
  • Hosting Method (Nginx/Apache/Docker): CPANEL (Apache)

Additional context
There are shelves created along with books in these shelves.
Application Homepage variable in settings can be set to any in the list and the error still exists.
Install into cpanel was done by following the guide:
https://www.warpconduit.net/2019/11/16/installing-bookstack-wiki-on-cpanel-shared-hosting/#more-915

Annotation 2020-04-13 152815

Originally created by @ShowMeIT on GitHub (Apr 22, 2020). **Describe the bug** Logging into any account (including admin account) shows a 'page not found error' at the top of the application homepage which it is currently set to show shelves (image attached). if you click 'return to home' or the bookstack logo in header, the page displays correctly. **Steps To Reproduce** Steps to reproduce the behavior: 1. Enter email & password at login screen 2. Click on 'login' 4. See error **Expected behavior** on login i would expect it to see the shelves **Screenshots** If applicable, add screenshots to help explain your problem. **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings):BookStack v0.28.3 - PHP Version: 7.3 - Hosting Method (Nginx/Apache/Docker): CPANEL (Apache) **Additional context** There are shelves created along with books in these shelves. Application Homepage variable in settings can be set to any in the list and the error still exists. Install into cpanel was done by following the guide: https://www.warpconduit.net/2019/11/16/installing-bookstack-wiki-on-cpanel-shared-hosting/#more-915 ![Annotation 2020-04-13 152815](https://user-images.githubusercontent.com/51915383/79950470-7500ed80-84ba-11ea-96d0-6aeccec74b3f.png)
Author
Owner

@ssddanbrown commented on GitHub (Apr 25, 2020):

Hi @ShowMeIT,
Do you have BookStack installed on sub-path (https://example.com/bookstack)?
Or is it on the top-level of the domain (https://example.com)?

Have you set the APP_URL parameter in your .env?

I'm guessing you see some kind of different URL after logging in that's not the homepage? If you can let me know the path you're being directed to (Don't need the domain if you want to keep that hidden, just everything after the domain) that would be useful to diagnose what's happening.

@ssddanbrown commented on GitHub (Apr 25, 2020): Hi @ShowMeIT, Do you have BookStack installed on sub-path (https://example.com/bookstack)? Or is it on the top-level of the domain (https://example.com)? Have you set the `APP_URL` parameter in your `.env`? I'm guessing you see some kind of different URL after logging in that's not the homepage? If you can let me know the path you're being directed to (Don't need the domain if you want to keep that hidden, just everything after the domain) that would be useful to diagnose what's happening.
Author
Owner

@ShowMeIT commented on GitHub (Apr 26, 2020):

Hi,

Thank for having a look into this.

APP_URL points to https://'domain.com'/bookstack

public folder of book stack is located at public_html/bookstack
and BookStack install directory located back at same directory level as public_html.

url after login:

https://'domain.com'/bookstack/bookstack/index.php

@ShowMeIT commented on GitHub (Apr 26, 2020): Hi, Thank for having a look into this. APP_URL points to https://'domain.com'/bookstack public folder of book stack is located at public_html/bookstack and BookStack install directory located back at same directory level as public_html. url after login: https://'domain.com'/bookstack/bookstack/index.php
Author
Owner

@ssddanbrown commented on GitHub (Apr 26, 2020):

Okay, Just had a deep dive into this. Was really hoping the incoming URL could be re-written via Apache through the .htaccess to solve this but I could not find an ideal way.

The frameworks/Libraries at play (Laravel, Symfony) do some complex things when it comes to building the URL's used in this system. Think some of my work-arounds for other scenarios have caused trouble for this one.

It'll take me a while to properly try things out to make a fix in the core project, as I'll need to emulate all scenarios, but for now I think you might be able to get things working but opening the app/Http/Request.php file and overwriting it with the following:

<?php namespace BookStack\Http;

use Illuminate\Http\Request as LaravelRequest;

class Request extends LaravelRequest
{

    /**
     * Override the default request methods to get the scheme and host
     * to set the custom APP_URL, if set.
     * @return \Illuminate\Config\Repository|mixed|string
     */
    public function getSchemeAndHttpHost()
    {
        $base = config('app.url', null);

        if ($base) {
            $base = implode('/', array_slice(explode('/', trim($base, '/')), 0, 3));
        } else {
            $base = $this->getScheme().'://'.$this->getHttpHost();
        }

        return $base;
    }

    public function prepareBaseUrl()
    {
        $setUrl = config('app.url', null);
        if ($setUrl) {
            return '/' . implode('/', array_slice(explode('/', trim($setUrl, '/')), 3));
        }

        return parent::prepareBaseUrl();
    }

}
@ssddanbrown commented on GitHub (Apr 26, 2020): Okay, Just had a deep dive into this. Was really hoping the incoming URL could be re-written via Apache through the `.htaccess` to solve this but I could not find an ideal way. The frameworks/Libraries at play (Laravel, Symfony) do some complex things when it comes to building the URL's used in this system. Think some of my work-arounds for other scenarios have caused trouble for this one. It'll take me a while to properly try things out to make a fix in the core project, as I'll need to emulate all scenarios, but for now I think you might be able to get things working but opening the `app/Http/Request.php` file and overwriting it with the following: ```php <?php namespace BookStack\Http; use Illuminate\Http\Request as LaravelRequest; class Request extends LaravelRequest { /** * Override the default request methods to get the scheme and host * to set the custom APP_URL, if set. * @return \Illuminate\Config\Repository|mixed|string */ public function getSchemeAndHttpHost() { $base = config('app.url', null); if ($base) { $base = implode('/', array_slice(explode('/', trim($base, '/')), 0, 3)); } else { $base = $this->getScheme().'://'.$this->getHttpHost(); } return $base; } public function prepareBaseUrl() { $setUrl = config('app.url', null); if ($setUrl) { return '/' . implode('/', array_slice(explode('/', trim($setUrl, '/')), 3)); } return parent::prepareBaseUrl(); } } ```
Author
Owner

@ShowMeIT commented on GitHub (Apr 27, 2020):

Code overwrite was successful.
Thank you for a great product!

@ShowMeIT commented on GitHub (Apr 27, 2020): Code overwrite was successful. Thank you for a great product!
Author
Owner

@calliostro commented on GitHub (Apr 11, 2022):

Hi @ssddanbrown

I can confirm the problem at least for Apache installations after debugging. You have already presented a working solution by changing the request.php.

Is there a plan to check in the change into the repository? Otherwise it would be helpful to include a note with a link to this in the documentation.

Thank you!
Joey

@calliostro commented on GitHub (Apr 11, 2022): Hi @ssddanbrown I can confirm the problem at least for Apache installations after debugging. You have already presented a working solution by changing the **request.php**. Is there a plan to check in the change into the repository? Otherwise it would be helpful to include a note with a link to this in the documentation. Thank you! Joey
Author
Owner

@ssddanbrown commented on GitHub (Apr 11, 2022):

@calliostro I've recently opened up #3364 which is targeted for the next feature release. It's not something I can quickly merge into a patch release due to the testing required for other environments that it may affect.

I've updated the milestone of this issue to reflect that same intended release.

@ssddanbrown commented on GitHub (Apr 11, 2022): @calliostro I've recently opened up #3364 which is targeted for the next feature release. It's not something I can quickly merge into a patch release due to the testing required for other environments that it may affect. I've updated the milestone of this issue to reflect that same intended release.
Author
Owner

@ssddanbrown commented on GitHub (Apr 25, 2022):

#3364 has now been merged so these changes will be part of the next feature release. I'll therefore close this off.

@ssddanbrown commented on GitHub (Apr 25, 2022): #3364 has now been merged so these changes will be part of the next feature release. I'll therefore close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1672