next-ai-editor 1.0.0 → 1.0.2

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.d.ts CHANGED
@@ -74,8 +74,10 @@ export declare interface ElementContext {
74
74
  * Get the AI Editor service URL
75
75
  *
76
76
  * Priority order:
77
- * 1. NEXT_PUBLIC_AI_EDITOR_SERVICE_URL environment variable
78
- * 2. Default to localhost:3456
77
+ * 1. NEXT_PUBLIC_AI_EDITOR_SERVICE_URL environment variable (for custom setups)
78
+ * 2. Auto-detect based on window.location.hostname
79
+ * - localhost -> http://localhost:3456
80
+ * - deployed -> https://${hostname}:3456
79
81
  */
80
82
  export declare function getServiceUrl(): string;
81
83
 
package/dist/index.js CHANGED
@@ -1006,12 +1006,12 @@ function MessageList({
1006
1006
  ] });
1007
1007
  }
1008
1008
  function getServiceUrl() {
1009
- var _a, _b;
1010
- if (typeof window !== "undefined" && ((_a = window.env) == null ? void 0 : _a.NEXT_PUBLIC_AI_EDITOR_SERVICE_URL)) {
1011
- return window.env.NEXT_PUBLIC_AI_EDITOR_SERVICE_URL;
1012
- }
1013
- if (typeof process !== "undefined" && ((_b = process.env) == null ? void 0 : _b.NEXT_PUBLIC_AI_EDITOR_SERVICE_URL)) {
1014
- return process.env.NEXT_PUBLIC_AI_EDITOR_SERVICE_URL;
1009
+ if (typeof window !== "undefined") {
1010
+ const hostname = window.location.hostname;
1011
+ if (hostname === "localhost" || hostname === "127.0.0.1") {
1012
+ return "http://localhost:3456";
1013
+ }
1014
+ return `https://${hostname}:3456`;
1015
1015
  }
1016
1016
  return "http://localhost:3456";
1017
1017
  }