Skip to content

Refactor WebSocket URL construction to prioritize X-Forwarded-Proto header#44

Merged
mahata merged 1 commit intomainfrom
fix-https-wss
Jul 10, 2025
Merged

Refactor WebSocket URL construction to prioritize X-Forwarded-Proto header#44
mahata merged 1 commit intomainfrom
fix-https-wss

Conversation

@mahata
Copy link
Copy Markdown
Owner

@mahata mahata commented Jul 10, 2025

This pull request refines the logic for constructing WebSocket URLs in the hono/routes/index.tsx file and updates the corresponding test cases in hono/routes/index.test.tsx. The changes ensure that the X-Forwarded-Proto header is prioritized when determining the protocol, improving support for proxied HTTPS requests.

@mahata mahata requested a review from Copilot July 10, 2025 07:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the WebSocket URL construction logic to prioritize the X-Forwarded-Proto header when determining the protocol for WebSocket connections. This improvement enhances support for applications running behind reverse proxies that handle HTTPS termination.

  • Changed protocol detection from URL-based to header-based approach using X-Forwarded-Proto
  • Updated test case to verify the new header-based protocol detection logic

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
hono/routes/index.tsx Modified WebSocket URL construction to check X-Forwarded-Proto header first
hono/routes/index.test.tsx Updated test to verify header-based protocol detection instead of URL-based
Comments suppressed due to low confidence (1)

hono/routes/index.test.tsx:37

  • The test coverage is incomplete. The original test for direct HTTPS requests was removed, but there should be tests covering: 1) direct HTTPS requests without proxy headers, 2) X-Forwarded-Proto with non-https values, and 3) missing X-Forwarded-Proto header scenarios.
  it("should construct correct WebSocket URL when X-Forwarded-Proto header is https", async () => {

Comment thread hono/routes/index.tsx
@mahata mahata merged commit 29c18de into main Jul 10, 2025
2 checks passed
@mahata mahata deleted the fix-https-wss branch July 10, 2025 07:48
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.

2 participants