@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/README.md CHANGED
@@ -9,20 +9,21 @@ Configure a `trackingId`, and optionally a `target` for which environment to use
9
9
 
10
10
  ## Environment targets
11
11
 
12
- Two environments — `local` and `production`. Legacy `dev` maps to `local`.
12
+ **Default: production (live).** Hosting your site on `localhost` does not switch environments.
13
13
 
14
- | Target | Layouts / config (Neon) | Events + personalize |
15
- |--------|-------------------------|----------------------|
16
- | `local` | `NEXT_PUBLIC_ORCHESTRATOR_URL` (e.g. `http://localhost:5001`) | `https://api-dev.amplifyup.ai` (AWS development) |
17
- | `production` | `https://amplifyup.ai` | `https://api.amplifyup.ai` |
14
+ Opt into `local` only when developing inside the AmplifyUp monorepo:
15
+
16
+ | Target | When | Layouts / config | Events + personalize |
17
+ |--------|------|------------------|----------------------|
18
+ | `production` (default) | Customer sites, staging, production | `https://amplifyup.ai` | `https://api.amplifyup.ai` |
19
+ | `local` (explicit) | AmplifyUp monorepo dev | `NEXT_PUBLIC_ORCHESTRATOR_URL` | `https://api-dev.amplifyup.ai` |
18
20
 
19
21
  ```bash
20
- # Demo on http://localhost:5000 — pages from local Neon, events to AWS-dev
22
+ # AmplifyUp monorepo only (apps/demo, apps/orchestrator locally)
21
23
  NEXT_PUBLIC_ORCHESTRATOR_URL=http://localhost:5001
22
24
  NEXT_PUBLIC_AMPLIFYUP_TARGET=local
23
25
 
24
- # Optional: override AWS API base used by local (default api-dev)
25
- # NEXT_PUBLIC_AMPLIFYUP_API_URL=https://api-dev.amplifyup.ai
26
+ # Customer sites: omit NEXT_PUBLIC_AMPLIFYUP_TARGET — always live
26
27
  ```
27
28
 
28
29
  Check active URLs in the browser: `AmplifyUp.getStatus()`
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { P as PageConfig } from './types-Xv9P55Dj.mjs';
3
+ import { P as PageConfig } from './types-B2Swk8BW.mjs';
4
4
 
5
5
  interface AmplifyRendererProps {
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { P as PageConfig } from './types-Xv9P55Dj.js';
3
+ import { P as PageConfig } from './types-B2Swk8BW.js';
4
4
 
5
5
  interface AmplifyRendererProps {
6
6
  /**
@@ -242,14 +242,16 @@ function resolveAmplifyUpTarget(options) {
242
242
  if (isAmplifyUpTarget(envTarget)) {
243
243
  return normalizeAmplifyUpTarget(envTarget);
244
244
  }
245
- if (typeof window !== "undefined") {
246
- const host = window.location.hostname;
247
- if (host === "localhost" || host === "127.0.0.1") {
248
- return "local";
249
- }
250
- }
251
245
  return "production";
252
246
  }
247
+ function isRemoteOrchestratorUrl(orchestratorUrl) {
248
+ try {
249
+ const host = new URL(orchestratorUrl).hostname.toLowerCase();
250
+ return host !== "localhost" && host !== "127.0.0.1" && host !== "::1";
251
+ } catch {
252
+ return false;
253
+ }
254
+ }
253
255
  function localOrchestratorUrl() {
254
256
  const fromEnv = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_ORCHESTRATOR_URL : void 0;
255
257
  return (fromEnv || "http://localhost:5001").replace(/\/$/, "");
@@ -432,6 +434,12 @@ var AmplifyUpSDK = class {
432
434
  const previewOverrides = readPreviewQueryOverrides();
433
435
  if (previewOverrides.orchestratorUrl) {
434
436
  this.orchestratorUrl = previewOverrides.orchestratorUrl;
437
+ if (isRemoteOrchestratorUrl(previewOverrides.orchestratorUrl)) {
438
+ const prodUrls = resolveAmplifyUpUrls("production");
439
+ this.target = "production";
440
+ this.apiGatewayUrl = prodUrls.apiGatewayUrl;
441
+ this.decisionApiUrl = prodUrls.decisionApiUrl;
442
+ }
435
443
  }
436
444
  this.config = {
437
445
  trackingId: previewOverrides.trackingId || config.trackingId,