Closed EionRobb closed 2 months ago
@inertiajs/core
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?
encodeValuesOnly: true,
[
]
%5B
%5D
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
Inertia.useForm()
I think we should fix this yes. Could you please send in a PR? thanks!
@EionRobb ideally this would be configurable with the default being true.
true
Versions:
@inertiajs/core
version: v1.0.15Describe 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 urlSteps to reproduce:
Inertia.useForm()
with an array to get a request