Skip to content

[6.x] Do not set the Inertia root view globally#14942

Merged
jasonvarga merged 2 commits into
statamic:6.xfrom
lazerg:fix-inertia-cp-root-view
Jul 6, 2026
Merged

[6.x] Do not set the Inertia root view globally#14942
jasonvarga merged 2 commits into
statamic:6.xfrom
lazerg:fix-inertia-cp-root-view

Conversation

@lazerg

@lazerg lazerg commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

CpServiceProvider::boot() set the Inertia root view globally with Inertia::setRootView('statamic::layout'), so apps that render their own Inertia frontend outside the control panel inherited it and their pages (including Inertia error responses) rendered inside Statamic's CP layout. The control panel already sets its own root view via the HandleInertiaRequests middleware on every CP route, so the global call isn't needed and just leaks into the host app.

Fixes #14619

@lazerg

lazerg commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@jasonvarga mind reviewing this when you have a moment, it removes a redundant global Inertia root-view call that was leaking into host apps outside the CP.

@duncanmcclean

duncanmcclean commented Jul 6, 2026

Copy link
Copy Markdown
Member

Thanks for the PR. We'll review it when we can.

In the meantime, you can pull this PR into your project with a composer patch.

@jasonvarga

Copy link
Copy Markdown
Member

Thanks for this — moving the rootView to HandleInertiaRequests is the right call.

One edge case: exception rendering for CP routes can happen before HandleInertiaRequests has run, so the root view wasn't always set yet — it fell back to Inertia's default (app) and crashed with View [app] not found.

Pushed a follow-up commit that pins ->rootView(...) explicitly in RendersControlPanelExceptions and RendersHttpExceptions, backed by a new HandleInertiaRequests::ROOT_VIEW constant. The RendersHttpExceptions one wasn't technically hitting the bug, but added it there too for consistency.

@jasonvarga jasonvarga enabled auto-merge (squash) July 6, 2026 19:55
@jasonvarga jasonvarga merged commit 1304b85 into statamic:6.x Jul 6, 2026
19 checks passed
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.

CpServiceProvider::boot() sets Inertia rootView globally, breaking apps that run Inertia outside the CP

3 participants