Skip to content

Preserve sec-fetch-dest for passed navigate requests #1803

@ErikWitt

Description

@ErikWitt

For navigate requests the sec-fetch-dest header is set to document. Once a service worker is introduced that simply forwards the request to the network, the sec-fetch-dest header changes to empty.

There are systems that rely on that header on server side to detect navigate requests and act accordingly. Shopify for example has some language/currency persistence logic that uses it.

Introducing a service worker that forwards requests (e.g. to cache responses for offline handling), breaks functionality.

I would argue that a navigate request from the browser should behave the same when proxied through a service worker. If this cannot be assumed by the developer, it gets very hard to implement service worker without potentially breaking functionality.

To have a reproducable example, here is a test website: https://dm-clone-optimized.app.baqend.com/fetch-dest/

It installs a service worker and when reloading you can see the sec-fetch-dest header being different depending on whether you bypass the service worker or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions