Skip to content

Plugin breaks Playwright tests with Vite preview server due to "accepts" header rules #79

@james-camilleri

Description

@james-camilleri

This is a bit of a weird one, but I'm pretty sure I've narrowed down the cause.

Symptoms
Playwright tests running on a vite preview server fail to start. Playwright is unable to detect that that the server is running.

Probable cause
Playwright sends a GET request with an Accepts: */* header to the configured URL to determine if the server is running. This plugin overwrites the default headers accepted for rewrites by the connect-history-api-fallback module here:

htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
Since */* is no longer a valid header for a rewrite, Playwright's requests are never handled, and it can never tell that the server is running.

Possible solution
Add */* to the accepted headers, or reinstate the default ones. If that would break things, perhaps make them configurable somehow. I'm not sure what the context was behind changing the defaults initially so I'm not sure what the best solution is in this scenario.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions