Skip to content

Use subpath in websocket URL - #471

Merged
ravjotbrar merged 3 commits into
valkey-io:mainfrom
tkesgar:patch-1
Aug 13, 2026
Merged

Use subpath in websocket URL#471
ravjotbrar merged 3 commits into
valkey-io:mainfrom
tkesgar:patch-1

Conversation

@tkesgar

@tkesgar tkesgar commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Slightly adjusts the websocket URL to use subpath. This allows us to support subpath deployments without having to rebuild the frontend:

  • Normal deployment:
    • URL: https://valkey.mywebsite.com/
    • WS URL: wss://valkey.mywebsite.com/
  • Subpath deployment:
    • URL: https://mywebsite.com/valkey/
    • WS URL: wss://mywebsite.com/valkey/

Currently we use ws[s]://window.location.host, which ignores the root path of our subpath deployment even with rewrite in reverse proxy (e.g. https://mywebsite.com/valkey/ => wss://https://mywebsite.com).

We can instead derive the websocket URL from window.location.origin + window.location.pathname, which gives us the full path without hash part or search query.

Refactor websocket host determination logic to a separate function.

Signed-off-by: Ted Kesgar <tkesgar@users.noreply.github.com>
Signed-off-by: Ted Kesgar <tkesgar@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b96cb392-3b40-46c4-a67a-3a3162d4302c

📥 Commits

Reviewing files that changed from the base of the PR and between 4b08ff3 and 553b13b.

📒 Files selected for processing (1)
  • apps/frontend/src/state/epics/wsEpics.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/frontend/src/state/epics/wsEpics.ts

📝 Walkthrough

Walkthrough

The WebSocket URL construction now uses getWebsocketURL(). Electron uses ws://localhost:8080. Other environments derive the WebSocket URL from window.location.origin and window.location.pathname.

Changes

WebSocket URL resolution

Layer / File(s) Summary
Centralize WebSocket URL selection
apps/frontend/src/state/epics/wsEpics.ts
getWebsocketURL() selects the Electron localhost endpoint or derives the WebSocket URL from the browser origin and pathname. The previous protocol and host construction was removed.

Mergeability Score: ⚪ Minimal · up to 553b1

This localized change updates websocket URLs to preserve deployment subpaths, and no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding the deployment subpath to the WebSocket URL.
Description check ✅ Passed The description provides a clear summary and examples, but it does not include the requested screenshot or video.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: dependency version conflict. Check your lock file or package.json.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tkesgar tkesgar changed the title Use subpath in websocket Use subpath in websocket URL Aug 12, 2026
Comment thread apps/frontend/src/state/epics/wsEpics.ts
Co-authored-by: Ravjot Brar <83892020+ravjotbrar@users.noreply.github.com>
Signed-off-by: Ted Kesgar <tkesgar@users.noreply.github.com>
@ravjotbrar

Copy link
Copy Markdown
Collaborator

One thing to note: users deploying behind a subpath proxy will need to set VALKEY_ADMIN_ALLOWED_WS_ORIGINS to include the proxy's origin (e.g., http://myproxy:9090)

@ravjotbrar
ravjotbrar merged commit 1458c35 into valkey-io:main Aug 13, 2026
9 of 10 checks passed
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