Skip to content

fix(http2): avoid including default port in authority string#7256

Merged
DigitalBrainJS merged 2 commits intoaxios:v1.xfrom
Subhan030:v1.x
Dec 19, 2025
Merged

fix(http2): avoid including default port in authority string#7256
DigitalBrainJS merged 2 commits intoaxios:v1.xfrom
Subhan030:v1.x

Conversation

@Subhan030
Copy link
Contributor

@Subhan030 Subhan030 commented Nov 23, 2025

Fix: Remove Default Port From HTTP/2 :authority Header (#7249)

Problem

Certain HTTP/2 servers reject requests when the :authority header includes a default port value that is already implied by the protocol. Axios previously generated an authority string like:

:authority: example.com:443

Even when the URL did not explicitly specify a port. Some HTTP/2 implementations expect the header to omit default ports and therefore responded with connection errors or rejected the request because the authority value was considered invalid.

Solution

The logic in lib/adapters/http.js has been updated to:

  • Detect when a request is using HTTPS on port 443 or HTTP on 80
  • Automatically omit the port in :authority when it is the protocol default
  • Preserve ports when they are explicitly defined or are non-standard (e.g., 8080, 8443)

After this change, Axios now generates:

:authority: example.com

unless a custom port was intentionally provided.

Testing

A regression test has been added to confirm this behavior and ensure long-term consistency.

Impact

This change improves Axios compatibility with strict HTTP/2 servers by aligning the authority header formatting with expected protocol behavior. The update is non-breaking, does not alter API usage, and includes test coverage to prevent future regressions.

@DigitalBrainJS DigitalBrainJS merged commit d7e6065 into axios:v1.x Dec 19, 2025
11 checks passed
This was referenced Jan 25, 2026
This was referenced Feb 9, 2026
@ghdhbcdvjkjgzst-create
Copy link

رقم 7256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants