Skip to content

Timing of copying cookies during server-side fetch #17486

Open

Description

@Conduitry

Currently, incoming request cookies during an SSR'd request are not copied into an outgoing API request until inside the fetch that's passed to handleFetch. They are not already present on the request passed to handleFetch, and, if handleFetch changes the URL of the request, whether they are added during the (inner) fetch depends on the new changed hostname.

There are situations where this is undesirable. Consider, for example, the something else is serving both a SvelteKit app and an external API at the same origin, routing incoming requests as appropriate. Requests made from the browser can just be made same-origin as normal. Requests during SSR need to be rewritten to point to the API server on the internal network. But, doing this during handleFetch results in the expected cookies not being copied, since by the time the inner fetch sees the request, the hostname no longer matches that of the incoming request.

We should decide what we want to do about this. Changing the behavior would be a breaking change, unfortunately.

Activity

  1. added this to the 4.0 milestone on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeneeds-decisionNot sure if we want to do this yet, also design work needed

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions