fix(edge): override init when cloning with `NextRequest` (#54108)
### What? When cloning a `Request` with `NextRequest` the second argument needs to take precedence over the `Headers` set on the original request. ### Why? Follow-up of #53157 I checked the `Request` spec https://fetch.spec.whatwg.org/#request-class and following the order of execution, `init.headers` should indeed override the headers if the first param was `Request`. I verified this in the browser too: ```js const req1 = new Request("http://n", {headers: {"x-header": "foo"}}) const req2 = new Request(req1, {headers: {"x-header-2": "bar"}}) Object.fromEntries(req2.headers) // {x-header-2: "bar"} ``` So we should match `NextRequest` with this behavior. ### How? Pass the `init` to `super` when cloning the request. Closes NEXT-1521 Fixes #54094
Showing
Please
register
or
sign in
to comment