diff --git a/packages/server/next/app/env.ts b/packages/server/next/app/env.ts
new file mode 100644
index 0000000000000000000000000000000000000000..d097278f370d8b3632ffa337bea5148b230e4f9a
--- /dev/null
+++ b/packages/server/next/app/env.ts
@@ -0,0 +1,12 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+"use client";
+
+/**
+ * A helper function to get environment variables from the window object
+ * @param name - The name of the environment variable to get
+ * @returns The value of the environment variable
+ */
+export const getEnv = (name: string) => {
+  if (typeof window === "undefined") return undefined;
+  return (window as any).LLAMAINDEX[name];
+};
diff --git a/packages/server/next/app/layout.tsx b/packages/server/next/app/layout.tsx
index d6a70e50354b4c86ec12edda3d466f743fa78767..8da554c3372259a4402144782d8addb69b0cbdf6 100644
--- a/packages/server/next/app/layout.tsx
+++ b/packages/server/next/app/layout.tsx
@@ -14,6 +14,7 @@ export default function RootLayout({
   return (
     <html lang="en">
       <body>{children}</body>
+      <script async src="./config.js"></script>
     </html>
   );
 }
diff --git a/packages/server/next/app/page.tsx b/packages/server/next/app/page.tsx
index 48c85c6f970e61028eb99c516c9e9fc0318fd23f..07a9a36d553b777ea9b9afdcb4c55fbe2a4e21f7 100644
--- a/packages/server/next/app/page.tsx
+++ b/packages/server/next/app/page.tsx
@@ -1,13 +1,14 @@
 "use client";
 import { ChatSection } from "@llamaindex/chat-ui";
 import { useChat } from "ai/react";
+import { getEnv } from "./env";
 
 export default function Page() {
-  const handler = useChat();
+  const handler = useChat({ api: getEnv("CHAT_API") });
   return (
-    <div className="h-screen flex items-center justify-center">
+    <div className="flex h-screen items-center justify-center">
       <ChatSection
-        className="h-[72vh] w-[72vw] shadow-2xl rounded-2xl"
+        className="h-[72vh] w-[72vw] rounded-2xl shadow-2xl"
         handler={handler}
       />
     </div>
diff --git a/packages/server/next/next.config.ts b/packages/server/next/next.config.ts
index 7aee1c485c8173a74650c1058472da8b373eda4c..bb5895d04045f89d403d4791d6e77dc7d6fdadb3 100644
--- a/packages/server/next/next.config.ts
+++ b/packages/server/next/next.config.ts
@@ -2,6 +2,7 @@ import type { NextConfig } from "next";
 
 const nextConfig: NextConfig = {
   distDir: "../.next",
+  output: "export",
 };
 
 export default nextConfig;
diff --git a/packages/server/next/public/config.js b/packages/server/next/public/config.js
new file mode 100644
index 0000000000000000000000000000000000000000..e38e1a68f9838e989e6480e286275584e275d40c
--- /dev/null
+++ b/packages/server/next/public/config.js
@@ -0,0 +1,3 @@
+window.LLAMAINDEX = {
+  CHAT_API: "http://localhost:3000/api/chat",
+};
diff --git a/packages/server/src/types.ts b/packages/server/src/types.ts
index 6743a689b04e044e17e20cb8af4dd24d585592b6..5b2676c486bc8f1aaa296af2ce968f2314c8db95 100644
--- a/packages/server/src/types.ts
+++ b/packages/server/src/types.ts
@@ -21,6 +21,7 @@ export type AgentInput = {
  */
 export type ServerWorkflow =
   | Workflow<null, AgentInput, ChatResponseChunk>
+  // | Workflow<AgentWorkflowContext, AgentInputData, string>
   | AgentWorkflow;
 
 /**