Skip to content

ViewTransitions form submission behavior does not match browser-native behavior #9447

@knpwrs

Description

@knpwrs

Astro Info

Astro                    v4.0.6
Node                     v18.18.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When submitting a form with method="POST" with the <ViewTransitions /> component, Astro submits the form as Content-Type: multipart/form-data, whereas the browser default behavior without JavaScript is to submit as Content-Type: application/x-www-form-urlencoded.

In the linked repo, I have the server log out await Astro.request.text() on the server side. It looks like this:

image

When you disable JavaScript, or just do this same thing on a non-astro project, the log looks like this:

image

See also the request header with JavaScript enabled:

image

Vs JavaScript disabled:

image

What's the expected result?

The ViewTransitions progressive enhancement should submit forms as Content-Type: application/x-www-form-urlencoded.

Here is where Remix handles this in their codebase: https://github.com/remix-run/remix/blob/e26ddc724e78b9cf48110cd4f854516a7f1a87a2/packages/remix-react/data.ts#L95

Note that it might be hard to disable JavaScript while using StackBlitz. The easiest way to reproduce this bug is to clone the repo locally: https://github.com/knpwrs/astro-view-transition-post-bug

Link to Minimal Reproducible Example

https://stackblitz.com/~/github.com/knpwrs/astro-view-transition-post-bug

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions