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

Installing Flarum from /index.php causes wrong base url #1861

Closed
clarkwinkelmann opened this issue Aug 27, 2019 · 2 comments · Fixed by #1876
Closed

Installing Flarum from /index.php causes wrong base url #1861

clarkwinkelmann opened this issue Aug 27, 2019 · 2 comments · Fixed by #1876

Comments

@clarkwinkelmann
Copy link
Member

Bug Report

Current Behavior
Installing Flarum from /index.php works but causes an invalid url to be used in config.php, thus preventing access to the forum after install.

Steps to Reproduce

  1. Install Flarum according to https://flarum.org/docs/install.html
  2. At the step "navigate to your forum in a web browser", append /index.php at the end
  3. Follow the web installation
  4. When install is finished, you are redirected to /index.php which shows "Something went wrong while trying to load the full version of this site. Try hard-refreshing this page to fix the error" Accessing / shows the same error
  5. Assets are loaded from /index.php/assets/forum-575aab17.css which causes 404 errors
  6. You can observe /index.php being used in config.php

Expected Behavior
The installation page should either not be available at /index.php, or remove index.php from the install url automatically.

Screenshots
Probably not needed, let me know otherwise.

Environment

  • Flarum version: beta 9, and probably dev-master
  • Webserver: apache, but probably others
  • Hosting environment: tried locally
Output of "php flarum info", run this in terminal in your Flarum directory.

It's a blank install.

When enabling debug mode, the assets show the following 500 error:

Flarum\Http\Exception\RouteNotFoundException: /assets/forum-575aab17.css in file /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php on line 60
Stack trace:
  1. Flarum\Http\Exception\RouteNotFoundException->() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php:60
  2. Flarum\Http\Middleware\DispatchRoute->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
  3. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/ShareErrorsFromSession.php:58
  4. Flarum\Http\Middleware\ShareErrorsFromSession->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
  5. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/SetLocale.php:51
  6. Flarum\Http\Middleware\SetLocale->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
  7. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/CheckCsrfToken.php:25
  8. Flarum\Http\Middleware\CheckCsrfToken->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
  9. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php:34
 10. Flarum\Http\Middleware\AuthenticateWithSession->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 11. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php:52
 12. Flarum\Http\Middleware\RememberFromCookie->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 13. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/StartSession.php:62
 14. Flarum\Http\Middleware\StartSession->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 15. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/CollectGarbage.php:48
 16. Flarum\Http\Middleware\CollectGarbage->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 17. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php:29
 18. Flarum\Http\Middleware\ParseJsonBody->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 19. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/HandleErrorsWithWhoops.php:43
 20. Flarum\Http\Middleware\HandleErrorsWithWhoops->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 21. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php:83
 22. Zend\Stratigility\MiddlewarePipe->process() /home/clark/Projects/flarum-install/vendor/middlewares/request-handler/src/RequestHandler.php:84
 23. Middlewares\RequestHandler->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 24. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/middlewares/base-path-router/src/BasePathRouter.php:97
 25. Middlewares\BasePathRouter->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 26. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Middleware/OriginalMessages.php:41
 27. Zend\Stratigility\Middleware\OriginalMessages->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 28. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/middlewares/base-path/src/BasePath.php:53
 29. Middlewares\BasePath->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 30. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php:83
 31. Zend\Stratigility\MiddlewarePipe->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php:72
 32. Zend\Stratigility\MiddlewarePipe->handle() /home/clark/Projects/flarum-install/vendor/zendframework/zend-httphandlerrunner/src/RequestHandlerRunner.php:95
 33. Zend\HttpHandlerRunner\RequestHandlerRunner->run() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Server.php:46
 34. Flarum\Http\Server->listen() /home/clark/Projects/flarum-install/public/index.php:22

Possible Solution
Same as expected behavior.

Additional Context
Multiple people seem to have hit issues that could be related to this. Most recently https://discuss.flarum.org/d/21143-fatal-error-please-help but I'm not 100% sure this is the same issue. Other people had managed to get an index.php in their config.php and this is probably one way to inadvertently do it.

@franzliedke
Copy link
Contributor

@relax4o
Copy link
Contributor

relax4o commented Sep 7, 2019

The installation process where the base url is involved causes even more problems.

I've made some changes and when I test all cases properly, I can create a PR.

The issues I've found:

  • Using the console installer, if you omit the base url it'll add an incorrect setting mail_from => noreply@ which later if you don't fix this from the admin panel and you try to create (for example) a new account, the Mailer will throw an exception complaining about the email address format.
  • If you provide a base url but omit the protocol (http(s)) it'll break the website as it'll try to load assets from an incorrect url.
    Example: baseUrl = 'flarum.com' - Result: http://flarum.com/flarum.com/ANY-ASSETS

I can think of couple of solutions when the console installer is used:

  • Normalising the base url no matter what is provided (this works for console and web installers)
  • Requiring protocol
  • Making the base url mandatory + requiring protocol

Excuse me if the issues I've found sounds like they need to be in a different issue thread. I am kind of new to open source contribution.

relax4o added a commit to STotev/core that referenced this issue Sep 8, 2019
- Fix base url when is appended with a script filename
- Add default base url http://flarum.local when CLI wizard used
- Remove some code duplication
- Add minor improvement to the UX when CLI wizard used

Fixes flarum#1861
@relax4o relax4o mentioned this issue Sep 8, 2019
2 tasks
@franzliedke franzliedke added this to the 0.1.0-beta.11 milestone Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants