Skip to content

Commit 6af904e

Browse files
committed
chat: static build
1 parent ea9832b commit 6af904e

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
lines changed

chat/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A simple ChatGPT-like interface for AgentAPI. It's a demo showcasing how to use AgentAPI. 95% of the code was generated with Claude Code.
44

5-
## Setup
5+
## Development Setup
66

77
1. Ensure the AgentAPI backend server is running on `localhost:3284`
88

@@ -19,3 +19,25 @@ A simple ChatGPT-like interface for AgentAPI. It's a demo showcasing how to use
1919
```
2020

2121
4. Open [http://localhost:3000](http://localhost:3000) in your browser
22+
23+
## Static Build for Hosting
24+
25+
This application can be built as a static site for deployment to any static web hosting service.
26+
27+
### Building the Static Site
28+
29+
```bash
30+
# Generate the static export
31+
npm run export
32+
```
33+
34+
This will create a static build in the `out` directory, which can be deployed to any static hosting service.
35+
36+
### Testing the Static Build Locally
37+
38+
```bash
39+
# Serve the static files locally
40+
npm run serve-static
41+
```
42+
43+
This will start a local server to test the static build.

chat/next.config.mjs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3-
async headers() {
4-
return [
5-
{
6-
// matching all API routes
7-
source: "/api/:path*",
8-
headers: [
9-
{ key: "Access-Control-Allow-Credentials", value: "true" },
10-
{ key: "Access-Control-Allow-Origin", value: "*" },
11-
{ key: "Access-Control-Allow-Methods", value: "GET,DELETE,PATCH,POST,PUT" },
12-
{ key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" },
13-
]
14-
}
15-
];
16-
}
3+
// Enable static exports
4+
output: 'export',
5+
6+
// Disable image optimization since it's not supported in static exports
7+
images: {
8+
unoptimized: true,
9+
},
10+
11+
// Remove headers config for static export
1712
};
1813

1914
export default nextConfig;

chat/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"dev": "next dev --turbopack",
77
"build": "next build",
88
"start": "next start",
9-
"lint": "next lint"
9+
"lint": "next lint",
10+
"export": "next build",
11+
"serve-static": "npx serve out"
1012
},
1113
"dependencies": {
1214
"react": "^19.0.0",

chat/src/app/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
import { Suspense } from 'react';
12
import ChatInterface from '@/components/ChatInterface';
23

34
export default function Home() {
45
return (
56
<main className="flex min-h-screen flex-col items-center justify-between p-4 md:p-12">
67
<div className="w-full max-w-5xl">
78
<h1 className="text-3xl font-bold mb-6 text-center">AgentAPI Chat</h1>
8-
<ChatInterface />
9+
{/* Use Suspense boundary for useSearchParams in ChatInterface */}
10+
<Suspense fallback={<div className="text-center p-4">Loading chat interface...</div>}>
11+
<ChatInterface />
12+
</Suspense>
913
</div>
1014
</main>
1115
);

0 commit comments

Comments
 (0)