Skip to content

HandleInertiaRequests Silently Sends 0 length version: "" in responses if dependent middleware SubstituteBindings is also not loaded #803

@AlexRAtIB

Description

@AlexRAtIB

PHP package version

2.0.12

Inertia adapter(s) affected (if any)

  • React
  • Vue 3
  • Svelte
  • Not Applicable

Backend stack

Laravel Vapor 2.41.0
Laravel Framework 12.42.0
PHP 8.4
Installed using Laravel Vue3 Starter Pack

Describe the problem

Hello,

Forgive me if this belongs in the documentation ticket area, I wasn't sure if it was solely a documentation issue.

Inertia seems to send blank version strings causing 409 errors across navigations, specifically when a new routing group is registered besides the "Web" group.

It seems that this statement App::call in line ends up returning null, even if the user customized the version() function in HandleInertiaRequests.php

? App::call($this->version)

I found that loading this additional middleware resolves the issue:
\Illuminate\Routing\Middleware\SubstituteBindings::class

This was tested using dd(app()) function and inspecting the bindings array output when making requests to the new routing group. The HandleInertiaRequests entry was missing.

Steps to reproduce

Install Laravel Starter Kit, with Vue3

Follow Laravel docs to create a new subordinate routing group:
https://laravel.com/docs/12.x/routing#routing-customization

Add HandleInertiaRequests::class to the new routing group and create a response controller for it that uses Inertia::Render

Observe settings in HandleInertiaRequests not being used and the default class from inertia Response.php being used instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs more info/workNeeds more info from the author or additional work to get merged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions