Post form using application/x-www-form-urlencoded

I have a form that is supposed to encode data as application/x-www-form-urlencoded but on the server I always get multipart/form-data. As far as I understand the Turbo source code, it passes a FormData object to the fetch API, which will always be encoded as multipart/form-data.

Is there an option to tell Turbo to urlencode my data, that I missed? If not, is it planed for the future? Or is there a good reason to not use urlencoded forms, which I don’t get?

1 Like

The main reason is because multipart/form-data supports file uploads and application/x-www-form-urlencoded does not.

But I agree that a better implementation would be to check <form enctype> and default to URLSearchParams instead of FormData depending on the value.

1 Like

This does break my application. Ignoring the enctype parameter on a form and changing it does not seem like something that should be happening.

I’ve opened an issue for <form enctype> support: https://github.com/hotwired/turbo/issues/76