@amplifyup/sdk 0.1.4 → 0.1.5

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.
@@ -240,14 +240,16 @@ function resolveAmplifyUpTarget(options) {
240
240
  if (isAmplifyUpTarget(envTarget)) {
241
241
  return normalizeAmplifyUpTarget(envTarget);
242
242
  }
243
- if (typeof window !== "undefined") {
244
- const host = window.location.hostname;
245
- if (host === "localhost" || host === "127.0.0.1") {
246
- return "local";
247
- }
248
- }
249
243
  return "production";
250
244
  }
245
+ function isRemoteOrchestratorUrl(orchestratorUrl) {
246
+ try {
247
+ const host = new URL(orchestratorUrl).hostname.toLowerCase();
248
+ return host !== "localhost" && host !== "127.0.0.1" && host !== "::1";
249
+ } catch {
250
+ return false;
251
+ }
252
+ }
251
253
  function localOrchestratorUrl() {
252
254
  const fromEnv = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_ORCHESTRATOR_URL : void 0;
253
255
  return (fromEnv || "http://localhost:5001").replace(/\/$/, "");
@@ -430,6 +432,12 @@ var AmplifyUpSDK = class {
430
432
  const previewOverrides = readPreviewQueryOverrides();
431
433
  if (previewOverrides.orchestratorUrl) {
432
434
  this.orchestratorUrl = previewOverrides.orchestratorUrl;
435
+ if (isRemoteOrchestratorUrl(previewOverrides.orchestratorUrl)) {
436
+ const prodUrls = resolveAmplifyUpUrls("production");
437
+ this.target = "production";
438
+ this.apiGatewayUrl = prodUrls.apiGatewayUrl;
439
+ this.decisionApiUrl = prodUrls.decisionApiUrl;
440
+ }
433
441
  }
434
442
  this.config = {
435
443
  trackingId: previewOverrides.trackingId || config.trackingId,