@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.
package/dist/index.mjs CHANGED
@@ -230,14 +230,16 @@ function resolveAmplifyUpTarget(options) {
230
230
  if (isAmplifyUpTarget(envTarget)) {
231
231
  return normalizeAmplifyUpTarget(envTarget);
232
232
  }
233
- if (typeof window !== "undefined") {
234
- const host = window.location.hostname;
235
- if (host === "localhost" || host === "127.0.0.1") {
236
- return "local";
237
- }
238
- }
239
233
  return "production";
240
234
  }
235
+ function isRemoteOrchestratorUrl(orchestratorUrl) {
236
+ try {
237
+ const host = new URL(orchestratorUrl).hostname.toLowerCase();
238
+ return host !== "localhost" && host !== "127.0.0.1" && host !== "::1";
239
+ } catch {
240
+ return false;
241
+ }
242
+ }
241
243
  function localOrchestratorUrl() {
242
244
  const fromEnv = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_ORCHESTRATOR_URL : void 0;
243
245
  return (fromEnv || "http://localhost:5001").replace(/\/$/, "");
@@ -420,6 +422,12 @@ var AmplifyUpSDK = class {
420
422
  const previewOverrides = readPreviewQueryOverrides();
421
423
  if (previewOverrides.orchestratorUrl) {
422
424
  this.orchestratorUrl = previewOverrides.orchestratorUrl;
425
+ if (isRemoteOrchestratorUrl(previewOverrides.orchestratorUrl)) {
426
+ const prodUrls = resolveAmplifyUpUrls("production");
427
+ this.target = "production";
428
+ this.apiGatewayUrl = prodUrls.apiGatewayUrl;
429
+ this.decisionApiUrl = prodUrls.decisionApiUrl;
430
+ }
423
431
  }
424
432
  this.config = {
425
433
  trackingId: previewOverrides.trackingId || config.trackingId,