@pylonsync/sync 0.3.43 → 0.3.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +10 -12
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.43",
6
+ "version": "0.3.45",
7
7
  "type": "module",
8
8
  "main": "src/index.ts",
9
9
  "types": "src/index.ts",
package/src/index.ts CHANGED
@@ -1015,23 +1015,21 @@ export class SyncEngine {
1015
1015
  const isHttps = url.protocol === "https:";
1016
1016
  const scheme = isHttps ? "wss" : "ws";
1017
1017
 
1018
- // HTTPS deploys (Fly/Vercel/Cloudflare) terminate TLS at a single
1019
- // public port we can't assume port+1 is exposed. Callers should
1020
- // override via `wsUrl` in the sync-engine config (or set
1021
- // VITE_PYLON_WS_URL in Vite apps) when the WebSocket listens on a
1022
- // different hostname or a separate Fly service.
1018
+ // Production HTTPS deploys: multiplex WS on the same origin via
1019
+ // `/api/sync/ws`. The Pylon runtime accepts the Upgrade on its
1020
+ // main HTTP port (4321), so any reverse proxy that already
1021
+ // forwards `/api/*` carries the WebSocket through too. No
1022
+ // separate WS port to expose, no per-deployment wsUrl env var.
1023
1023
  //
1024
- // If the base URL has an explicit port (e.g. http://localhost:4321)
1025
- // we keep the historical port+1 convention that's what `pylon dev`
1026
- // hands to the developer on a single box. Otherwise we assume the
1027
- // WebSocket is reachable at the same hostname on the same scheme
1028
- // (most production proxies multiplex WS on 443 via the Upgrade
1029
- // header, and a future pylon build will do the same).
1024
+ // Local dev (`pylon dev` on `http://localhost:4321`) keeps the
1025
+ // legacy port+1 fallback so existing tutorials still work without
1026
+ // touching their app config the dedicated `:4322` listener is
1027
+ // still running there too.
1030
1028
  if (url.port) {
1031
1029
  const port = parseInt(url.port, 10);
1032
1030
  return `${scheme}://${url.hostname}:${port + 1}`;
1033
1031
  }
1034
- return `${scheme}://${url.hostname}`;
1032
+ return `${scheme}://${url.host}/api/sync/ws`;
1035
1033
  }
1036
1034
 
1037
1035
  /**