Repository navigation
feat(app-url-guard): add APP_URL mismatch developer guard package - #456
Merged
navneetkumar-pim-webkul merged 13 commits intoJun 4, 2026
Merged
navneetkumar-pim-webkul merged 13 commits into
navneetkumar-pim-webkul merged 13 commits into
Conversation
…-logout edge cases
dripar-webkul
force-pushed
the
feature/app-url-mismatch-warning
branch
from
June 2, 2026 06:15
10651c8 to
d708367
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new debug-only Webkul\AppUrlGuard package to detect APP_URL vs browser-host mismatches (a common cause of “CSS/JS not loading”), and provides a guided, in-page modal plus a lightweight check endpoint. The package is designed to be inert when APP_DEBUG=false and includes unit/feature coverage for normalization, injection behavior, and forced-logout behavior.
Changes:
- Add
AppUrlGuardpackage: global middleware to detect mismatches, inject a guided modal, and force-log-out mismatched admin sessions (debug-only). - Add a debug-only JSON “check” endpoint used by the modal to re-validate after the developer updates
.env. - Register the package in autoload/providers and add comprehensive Pest/PHPUnit test suite entries.
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Pest.php | Binds AppUrlGuard tests to AdminTestCase. |
| phpunit.xml | Adds AppUrlGuard unit + feature test suites. |
| composer.json | Adds PSR-4 autoload mapping for Webkul\\AppUrlGuard\\. |
| bootstrap/providers.php | Registers AppUrlGuardServiceProvider. |
| packages/Webkul/AppUrlGuard/src/Providers/AppUrlGuardServiceProvider.php | Loads routes/translations in debug and pushes the middleware onto the global stack. |
| packages/Webkul/AppUrlGuard/src/Http/Middleware/VerifyAppUrlMatches.php | Core guard logic: mismatch detection, logging, forced logout, and HTML injection. |
| packages/Webkul/AppUrlGuard/src/Http/Controllers/AppUrlGuardController.php | Debug-only JSON endpoint for “does APP_URL match now?”. |
| packages/Webkul/AppUrlGuard/src/Concerns/NormalizesUrl.php | Shared URL normalization used by middleware + endpoint. |
| packages/Webkul/AppUrlGuard/src/Routes/web.php | Defines the /app-url-guard/check route. |
| packages/Webkul/AppUrlGuard/src/Resources/views/warning.blade.php | Self-contained modal UI (HTML/CSS/JS) injected into mismatched HTML pages. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/en_US/app.php | English strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/en_GB/app.php | en_GB strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/en_AU/app.php | en_AU strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/en_NZ/app.php | en_NZ strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/ar_AE/app.php | Arabic strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/ca_ES/app.php | Catalan strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/da_DK/app.php | Danish strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/de_DE/app.php | German strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/es_ES/app.php | Spanish (ES) strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/es_VE/app.php | Spanish (VE) strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/fi_FI/app.php | Finnish strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/fr_FR/app.php | French strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/hi_IN/app.php | Hindi strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/hr_HR/app.php | Croatian strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/id_ID/app.php | Indonesian strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/it_IT/app.php | Italian strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/ja_JP/app.php | Japanese strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/ko_KR/app.php | Korean strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/mn_MN/app.php | Mongolian strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/nl_NL/app.php | Dutch strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/no_NO/app.php | Norwegian strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/pl_PL/app.php | Polish strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/pt_BR/app.php | Portuguese (BR) strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/pt_PT/app.php | Portuguese (PT) strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/ro_RO/app.php | Romanian strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/ru_RU/app.php | Russian strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/sv_SE/app.php | Swedish strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/tl_PH/app.php | Tagalog strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/tr_TR/app.php | Turkish strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/uk_UA/app.php | Ukrainian strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/vi_VN/app.php | Vietnamese strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/zh_CN/app.php | Simplified Chinese strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/src/Resources/lang/zh_TW/app.php | Traditional Chinese strings for the modal + forced-logout message. |
| packages/Webkul/AppUrlGuard/tests/Unit/VerifyAppUrlMatchesTest.php | Unit coverage for mismatch detection, response guards, security, and edge cases. |
| packages/Webkul/AppUrlGuard/tests/Unit/NormalizesUrlTest.php | URL normalization equivalence/difference matrix tests. |
| packages/Webkul/AppUrlGuard/tests/Unit/ArchTest.php | Architecture invariants (no debug calls, controller/middleware expectations). |
| packages/Webkul/AppUrlGuard/tests/Feature/AppUrlGuardEndpointTest.php | Feature coverage for endpoint behavior, middleware registration, injection, and force-logout behavior. |
…gets the unreachable APP_URL host
…chable-host redirects, treat loopback hosts as equal, and apply review fixes
…tch test is port-agnostic
This was referenced Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a debug-only
Webkul\AppUrlGuardpackage that detects when the browser host doesn't matchAPP_URL— the cause of the "styles/JS not loading" bug — and shows a guided fix modal styled to match the login page. Fully inert in production (APP_DEBUG=false).Behavior (debug only):
APP_URLvia a same-origin endpoint → reloads if fixed, warning toast if still wrong; All done → hard reload.Quality: Pint clean · 64 Pest tests / 101 assertions passing · no translation-audit issues. Self-contained view (scoped CSS, inline SVG — no font dependency), XSS-safe, handles Apache sub-dir & Nginx root.
Notes: Force-logout means an admin can't stay logged in while
APP_URLis wrong (intentional, debug-only). No Tailwind classes added — the injected modal uses scoped CSS by design.