inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.02k stars 405 forks source link

Incompatible with laravel vapor #1847

Closed EionRobb closed 2 months ago

EionRobb commented 2 months ago

Versions:

Describe the problem:

Currently the use of unencoded square brackets in the URL is causing 400 errors when running on laravel vapor. I need to use arrays in the get requests to work with spatie query builder in laravel for filtering.

Looking at the source, this is due to encodeValuesOnly: true, in https://github.com/inertiajs/inertia/blob/master/packages/core/src/url.ts#L25 which is preventing [ and ] being encoded as %5B and %5D - removing this line lets everything work. Is this line here just to make the URLs look nicer?

There's a bit more info about the cause of the 400 error on the vapor docs: https://docs.vapor.build/projects/troubleshooting.html#sandbox-url-returns-400-message-null

Maybe also relevant: https://www.rfc-editor.org/rfc/rfc1738#page-3 which says that [ and ] are unsafe and must always be encoded in a url

Steps to reproduce:

  1. Deploy a laravel app which uses inertia, onto AWS Lambda via vapor
  2. Use Inertia.useForm() with an array to get a request
driesvints commented 2 months ago

I think we should fix this yes. Could you please send in a PR? thanks!

driesvints commented 2 months ago

@EionRobb ideally this would be configurable with the default being true.