@sylphx/sdk 0.3.6 → 0.4.0

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.
@@ -457,7 +457,12 @@ function createSylphxMiddleware(userConfig = {}) {
457
457
  );
458
458
  }
459
459
  const secretKey = validateAndSanitizeSecretKey(rawSecretKey);
460
- const platformUrl = (userConfig.platformUrl || `https://${DEFAULT_SDK_API_HOST}`).trim();
460
+ const platformUrl = (() => {
461
+ if (userConfig.platformUrl) return userConfig.platformUrl.trim();
462
+ const parts = secretKey.split("_");
463
+ const ref = parts.length === 4 ? parts[2] : null;
464
+ return ref ? `https://${ref}.${DEFAULT_SDK_API_HOST}` : `https://${DEFAULT_SDK_API_HOST}`;
465
+ })();
461
466
  const namespace = getCookieNamespace(secretKey);
462
467
  const cookieNames = getCookieNames(namespace);
463
468
  const config = {
@@ -1815,7 +1820,7 @@ function configureServer(config) {
1815
1820
  const secretKey = validateAndSanitizeSecretKey(config.secretKey);
1816
1821
  serverConfig = {
1817
1822
  secretKey,
1818
- platformUrl: `https://${DEFAULT_SDK_API_HOST}`.trim()
1823
+ platformUrl: config.platformUrl?.trim() || `https://${DEFAULT_SDK_API_HOST}`.trim()
1819
1824
  };
1820
1825
  }
1821
1826
  function getConfig() {