Skip to content

Conversation

@eisbaw
Copy link
Contributor

@eisbaw eisbaw commented Oct 13, 2025

Summary

Fix WebSocket connection for HTTPS/ngrok access by automatically detecting the page protocol and using the appropriate WebSocket protocol.

See also #216

Changes

  • WebSocket protocol detection: Automatically use wss:// for HTTPS connections (e.g., ngrok) and ws:// for HTTP connections (localhost)
  • Rust formatting: Apply cargo fmt to fix code style issues across multiple files

Problem

When accessing the web UI via ngrok (HTTPS), the Send button didn't work because browsers block insecure WebSocket connections (ws://) from secure pages.

Solution

Modified src/lib/apiAdapter.ts to detect the page protocol and construct the WebSocket URL accordingly:

const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsUrl = `${wsProtocol}//${window.location.host}/ws/claude`;

Test plan

  • [✓] Test Send button on localhost (HTTP)
  • [✓] Test Send button via ngrok (HTTPS)
  • [✓] Verify WebSocket connection established correctly in both cases

🤖 Generated with Claude Code

- Fix WebSocket protocol to use wss:// for HTTPS (ngrok) and ws:// for HTTP (localhost)
- This resolves the issue where Send button doesn't work when accessed via ngrok
- Apply cargo fmt to fix Rust code formatting issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@eisbaw
Copy link
Contributor Author

eisbaw commented Oct 13, 2025

I have manually tested, localhost (http) and ngrok (https).

#216 was tested only with localhost, but now that I want to use it more - it failed via ngrok; hence this fix.

@123vivekr

@123vivekr
Copy link
Member

Thanks a lot @eisbaw

@123vivekr 123vivekr merged commit 70c16d8 into winfunc:main Oct 16, 2025
@123vivekr
Copy link
Member

Hi @eisbaw , I'm trying to understand how people use opcode and update our roadmap to make it better. Your feature ideas/use cases are cool and is something we'd like to have more of, so, if you have a few minutes, I'd love your input here: form link; this takes only 3 minutes.

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