Closed mickdermack closed 1 week ago
Since v6.16.1, undici sends the origin header as origin: https://origin.example.com, undefined in some cases.
origin: https://origin.example.com, undefined
This reproducibly happens when sending a POST request, with the origin header explicitly specified in headers and redirect: "error".
POST
headers
redirect: "error"
import { fetch } from 'undici'; async function repro() { let api_url = "http://localhost:8080"; let response = await fetch(api_url, { "headers": { "origin": "https://origin.example.com" }, "body": "", "method": "POST", "redirect": "error" }); } await repro();
I expected the origin header to be sent as origin: https://origin.example.com.
origin: https://origin.example.com
complete request sent with undici v6.16.1 and above:
POST / HTTP/1.1 host: localhost:8080 connection: keep-alive origin: https://origin.example.com, undefined content-type: text/plain;charset=UTF-8 accept: */* accept-language: * sec-fetch-mode: cors user-agent: undici accept-encoding: gzip, deflate content-length: 0
complete request sent with undici v6.16.0:
POST / HTTP/1.1 host: localhost:8080 connection: keep-alive origin: https://origin.example.com content-type: text/plain;charset=UTF-8 accept: */* accept-language: * sec-fetch-mode: cors user-agent: undici accept-encoding: gzip, deflate content-length: 0
Arch Linux, Node.js v22.3.0
@KhafraDev
Caused by 0a66d300a5eef00a0b6cf54245c2fba52acdcf73, will fix soon
Bug Description
Since v6.16.1, undici sends the origin header as
origin: https://origin.example.com, undefined
in some cases.This reproducibly happens when sending a
POST
request, with the origin header explicitly specified inheaders
andredirect: "error"
.Reproducible By
Expected Behavior
I expected the origin header to be sent as
origin: https://origin.example.com
.Logs & Screenshots
complete request sent with undici v6.16.1 and above:
complete request sent with undici v6.16.0:
Environment
Arch Linux, Node.js v22.3.0
Additional context