SpacetimeDB
SpacetimeDB copied to clipboard
TypeScript SDK - withUri should be able to take either HTTPS or WSS for a secure connection
If you supply .withUri("https://maincloud.spacetimedb.com") instead of .withUri("wss://maincloud.spacetimedb.com") then you will get a ws:// connection instead of a wss:// connection. If the user supplies a https:// connection string we should automatically convert that to wss://. Both the C# and rust SDKs do this.
Discord thread: https://discord.com/channels/1037340874172014652/1362951793595650148/1362951793595650148
I believe this got superseded by @cloutiertyler #3248
If I got this correctly, the conversion is now handled in crates/bindings-typescript/src/sdk/db_connection_impl.ts:
const url = new URL(uri.toString());
if (!/^wss?:/.test(uri.protocol)) {
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
}
So .withUri("https://...") will correctly produce a wss:// connection.