Browse Source

Fix WebSocket protocol detection for HTTP deployments (v0.36.3)

- Fix minifier optimization bug that caused ws:// protocol detection to
  always return wss:// by using startsWith('https') instead of === 'https:'
- Update App.svelte to use protocol detection in all 5 WebSocket URL
  construction locations (compose, delete, repost, publish functions)
- Update constants.js DEFAULT_RELAYS to use the same minifier-safe pattern
- Enables web UI to work correctly on HTTP-only relay deployments

Files modified:
- app/web/src/App.svelte: Fix 5 hardcoded wss:// URLs with protocol detection
- app/web/src/constants.js: Fix DEFAULT_RELAYS protocol detection
- pkg/version/version: Bump to v0.36.3

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
main
mleku 4 weeks ago
parent
commit
1bbbfb5570
No known key found for this signature in database
  1. 15
      app/web/src/App.svelte
  2. 4
      app/web/src/constants.js
  3. 2
      pkg/version/version

15
app/web/src/App.svelte

@ -236,7 +236,8 @@
console.log("Delete event tags:", signedDeleteEvent.tags); console.log("Delete event tags:", signedDeleteEvent.tags);
// Publish to the ORLY relay using WebSocket authentication // Publish to the ORLY relay using WebSocket authentication
const relayUrl = `wss://${window.location.host}`; const wsProtocol = window.location.protocol.startsWith('https') ? 'wss:' : 'ws:';
const relayUrl = `${wsProtocol}//${window.location.host}/`;
try { try {
const result = await publishEventWithAuth( const result = await publishEventWithAuth(
@ -381,7 +382,8 @@
} else { } else {
// Admin/owner deleting someone else's event - only publish to local relay // Admin/owner deleting someone else's event - only publish to local relay
// We need to publish only to the local relay, not external ones // We need to publish only to the local relay, not external ones
const localRelayUrl = `wss://${window.location.host}/`; const wsProto = window.location.protocol.startsWith('https') ? 'wss:' : 'ws:';
const localRelayUrl = `${wsProto}//${window.location.host}/`;
// Create a modified client that only connects to the local relay // Create a modified client that only connects to the local relay
const localClient = new NostrClient(); const localClient = new NostrClient();
@ -636,7 +638,8 @@
} }
try { try {
const localRelayUrl = `wss://${window.location.host}/`; const wsProto = window.location.protocol.startsWith('https') ? 'wss:' : 'ws:';
const localRelayUrl = `${wsProto}//${window.location.host}/`;
console.log( console.log(
"Reposting event to local relay:", "Reposting event to local relay:",
localRelayUrl, localRelayUrl,
@ -698,7 +701,8 @@
try { try {
// Get user's write relays // Get user's write relays
const writeRelays = await getUserWriteRelays(); const writeRelays = await getUserWriteRelays();
const localRelayUrl = `wss://${window.location.host}/`; const wsProto = window.location.protocol.startsWith('https') ? 'wss:' : 'ws:';
const localRelayUrl = `${wsProto}//${window.location.host}/`;
// Always include local relay // Always include local relay
const allRelays = [ const allRelays = [
@ -2603,7 +2607,8 @@
} }
// Publish to the ORLY relay using WebSocket (same address as current page) // Publish to the ORLY relay using WebSocket (same address as current page)
const relayUrl = `wss://${window.location.host}`; const wsProtocol = window.location.protocol.startsWith('https') ? 'wss:' : 'ws:';
const relayUrl = `${wsProtocol}//${window.location.host}/`;
// Use the authentication module to publish the event // Use the authentication module to publish the event
const result = await publishEventWithAuth( const result = await publishEventWithAuth(

4
app/web/src/constants.js

@ -1,8 +1,10 @@
// Default Nostr relays for searching // Default Nostr relays for searching
// Use startsWith to avoid minifier optimization issues
const wsProtocol = window.location.protocol.startsWith('https') ? 'wss:' : 'ws:';
export const DEFAULT_RELAYS = [ export const DEFAULT_RELAYS = [
// Use the local relay WebSocket endpoint // Use the local relay WebSocket endpoint
// Automatically use ws:// for http:// and wss:// for https:// // Automatically use ws:// for http:// and wss:// for https://
`${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${window.location.host}/`, `${wsProtocol}//${window.location.host}/`,
]; ];
// Replaceable kinds for the recovery dropdown // Replaceable kinds for the recovery dropdown

2
pkg/version/version

@ -1 +1 @@
v0.36.2 v0.36.3

Loading…
Cancel
Save