Fix Electron CSP blocking websocket connections#410
Merged
Conversation
Signed-off-by: ravjotb <ravjot.brar@improving.com>
| "default-src 'self'; script-src 'self'; " + | ||
| "style-src 'self' 'unsafe-inline'; " + | ||
| "connect-src 'self'; " + | ||
| "connect-src 'self' ws://localhost:* http://localhost:*; " + |
Collaborator
There was a problem hiding this comment.
Is there the ability to scope to specific ports, not all?
Collaborator
Author
There was a problem hiding this comment.
Unfortunately not, due to the user having the ability to override the main server's default port, which is 8080.
| "default-src 'self'; script-src 'self'; " + | ||
| "style-src 'self' 'unsafe-inline'; " + | ||
| "connect-src 'self'; " + | ||
| "connect-src 'self' ws://localhost:* http://localhost:*; " + |
Collaborator
There was a problem hiding this comment.
It seems like we need to keep it consistent. - https://github.com/valkey-io/valkey-admin/blob/main/apps/frontend/index.html . Would it be better to add a small comment cross-referencing them?
Collaborator
Author
There was a problem hiding this comment.
We could probably actually remove this one and keep the meta tag in index.html. Will do in a future PR to avoid any big changes before the release.
alexey-temnikov
approved these changes
Jul 23, 2026
alexey-temnikov
left a comment
Collaborator
There was a problem hiding this comment.
Approved with few questions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The onHeadersReceived CSP in electron.main.js had connect-src 'self' which overrides the permissive meta tag in index.html. When both are present, the browser enforces the intersection (most restrictive). Add ws://localhost:* and http://localhost:* to match the meta tag.
Change Visualization
Include a screenshot/video of before and after the change.