Skip to content

feat: redirect users to installer on fresh installations#2438

Open
apple050620312 wants to merge 6 commits into
pelican-dev:mainfrom
apple050620312:feat/issue-2413
Open

feat: redirect users to installer on fresh installations#2438
apple050620312 wants to merge 6 commits into
pelican-dev:mainfrom
apple050620312:feat/issue-2413

Conversation

@apple050620312

Copy link
Copy Markdown
Contributor

Closes #2413

What does this PR do?

This PR resolves an issue where a fresh installation (e.g. via Docker) throws a generic 500 error when visiting the root URL (/) or /login due to the uninitialized database.

Instead of showing a generic error, this PR introduces a global RedirectIfNotInstalled middleware that automatically guides the operator to the /installer if the panel has not yet completed its first-run setup (config('app.installed') === false).

Implementation Details

  • Added App\Http\Middleware\RedirectIfNotInstalled to gracefully intercept incoming requests.
  • If the application is not installed:
    • Standard web requests are redirected to route('installer').
    • API and JSON requests are rejected with a 503 Service Unavailable response.
    • Required /installer and /livewire/* routes are explicitly allowed to proceed so the setup process functions correctly.
  • Appended the middleware to the global stack in bootstrap/app.php.

How to Test

  1. Set up a fresh instance (e.g., using the ghcr.io/pelican-dev/panel:latest Docker image) without completing the web installer.
  2. Visit the root URL https://panel.example.com/ or https://panel.example.com/login.
  3. Verify that the application redirects you to https://panel.example.com/installer instead of showing a generic "Something went wrong" modal.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b72446cb-3309-48c0-a5f0-feb3ba9eac90

📥 Commits

Reviewing files that changed from the base of the PR and between e3d10ec and 6840668.

📒 Files selected for processing (3)
  • app/Http/Middleware/RedirectIfNotInstalled.php
  • bootstrap/app.php
  • routes/base.php
💤 Files with no reviewable changes (1)
  • app/Http/Middleware/RedirectIfNotInstalled.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • routes/base.php
  • bootstrap/app.php

📝 Walkthrough

Walkthrough

A new middleware checks whether the app is installed, redirects uninstalled requests to the installer route, registers that middleware globally, and excludes it from the installer route itself.

Changes

Installation guard middleware

Layer / File(s) Summary
Middleware logic
app/Http/Middleware/RedirectIfNotInstalled.php
Adds RedirectIfNotInstalled with a handle method that forwards installed requests and redirects uninstalled requests to the installer route.
Middleware registration
bootstrap/app.php, routes/base.php
Imports the middleware, adds it to the global middleware stack, and excludes it from the installer route along with auth.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: redirecting fresh installs to the installer.
Description check ✅ Passed The description matches the change set and describes the installer redirect behavior.
Linked Issues check ✅ Passed The PR implements the requested fresh-install handling by redirecting incomplete installs to /installer.
Out of Scope Changes check ✅ Passed The changes stay focused on the fresh-install redirect flow and related middleware wiring.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Http/Middleware/RedirectIfNotInstalled.php`:
- Around line 22-30: The RedirectIfNotInstalled middleware is blocking the /up
health check by treating it like a normal unauthenticated route. Update the
allowlist check in the middleware’s request guard so that /up (the health route
registered in bootstrap/app.php) bypasses the installer redirect alongside
installer and livewire paths. Keep the existing JSON/API handling unchanged, and
make sure the redirect only applies to non-allowed, non-API routes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bc47b51d-858d-4485-ae05-922e4e10c22a

📥 Commits

Reviewing files that changed from the base of the PR and between b8bbf29 and aec4e62.

📒 Files selected for processing (2)
  • app/Http/Middleware/RedirectIfNotInstalled.php
  • bootstrap/app.php

Comment thread app/Http/Middleware/RedirectIfNotInstalled.php Outdated
Comment thread app/Http/Middleware/RedirectIfNotInstalled.php Outdated
Comment thread bootstrap/app.php Outdated
Comment thread bootstrap/app.php Outdated
Comment thread app/Http/Middleware/RedirectIfNotInstalled.php Outdated
@apple050620312 apple050620312 requested a review from lancepioch July 9, 2026 03:39

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@routes/base.php`:
- Line 7: The installer route exemption currently only applies to the main GET
entrypoint, so Livewire update requests are still being caught by
RedirectIfNotInstalled through the web middleware stack. Update the Livewire
update handling so /livewire/update is also excluded during installation, using
the existing route setup in routes/base.php and the RedirectIfNotInstalled
middleware as the place to verify the exemption.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0f80fc7e-eb9c-455a-8446-1d169f4e060e

📥 Commits

Reviewing files that changed from the base of the PR and between e3d10ec and ae954ed.

📒 Files selected for processing (3)
  • app/Http/Middleware/RedirectIfNotInstalled.php
  • bootstrap/app.php
  • routes/base.php
💤 Files with no reviewable changes (1)
  • app/Http/Middleware/RedirectIfNotInstalled.php

Comment thread routes/base.php Outdated
@apple050620312

Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fresh install should guide users to installer instead of generic login error

2 participants