Configuration

Via the configuration file and/or a custom middleware.

Configuration file

The package can be globally configured via config/inertia.py configuration file.

VariableDescription

PUBLIC_PATH

Absolute path to mix-manifest.json location. It's needed for computing js assets version.

Default: project root

ROOT_VIEW

Global root template view used by your Inertia Controllers to render the page. Specify the name of the view without .html. See Root view.

Default: "app"

INCLUDE_ROUTES

Include server-side routes as JSON payload in Inertia response (as a prop). See routing.

Default: False

Overriding Middleware

The `InertiaMiddleware` can be overriden to define the root view and the way assets version is computed. You just have to create a middleware in your app inheriting from the `InertiaMiddleware` class.

app/http/middleware/HandleInertiaRequests.py
from masonite.inertia import InertiaMiddleware

class HandleInertiaRequests(InertiaMiddleware):
    
    root_view = "other_app"
    
    def version(self, request):
         return "123"

Then include this middleware in the HTTP middleware instead of the original one.

Last updated