h3 icon indicating copy to clipboard operation
h3 copied to clipboard

Missed typed header value type

Open maxdzin opened this issue 1 year ago • 3 comments

Environment

Nodejs v20.15.0

Reproduction

_

Describe the bug

Since the latest release of unjs/h3 v1.12.0, TypedHeaders 'retry-after' is missing string type: https://github.com/unjs/h3/blob/6765a6e2026e203a4ea775964f855070e114f0bf/src/types/_headers.ts#L42 According to MDN docs, it can take as number (seconds) as well as a date string: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After

Additional context

In Nuxt app, I'm trying to set the response headers by this:

...
setResponseHeader(event, 'Retry-After', (maintenanceDateTo || dateNextDay).toUTCString())

Previously it worked fine since number or string values were valid. Now TS drops an error in a reason described above.

Logs

No response

maxdzin avatar Jun 20 '24 21:06 maxdzin

Currently it is set to string. Also setResponseHeaders is deprecated. @pi0 I think this issue can be safely closed.

s0h311 avatar Oct 05 '24 19:10 s0h311

@s0h311 nope, it uses AnyString now, but it should also allow number.

maxdzin avatar Oct 06 '24 06:10 maxdzin

Should be closed in v2, since v2 removed these types and all headers will be plain string. 🤔

kricsleo avatar Apr 24 '25 08:04 kricsleo