Spaces:
Sleeping
Sleeping
Commit
·
17e5473
1
Parent(s):
711c2ee
chore: update Next.js configuration for image domains, adjust API fetch URLs, and add health check endpoint in backend
Browse files- app/page.tsx +2 -2
- backend/app/main.py +9 -1
- backend/requirements.txt +2 -1
- next.config.ts +7 -1
app/page.tsx
CHANGED
@@ -136,7 +136,7 @@ export default function Home() {
|
|
136 |
});
|
137 |
}, updateInterval);
|
138 |
|
139 |
-
const response = await fetch("
|
140 |
method: "POST",
|
141 |
headers: {
|
142 |
"Content-Type": "application/json",
|
@@ -156,7 +156,7 @@ export default function Home() {
|
|
156 |
if (data.success && (data.filenames || data.filename)) {
|
157 |
const filenames = data.filenames || (data.filename ? [data.filename] : []);
|
158 |
const imageUrls = filenames.map(filename =>
|
159 |
-
|
160 |
);
|
161 |
setGeneratedImages(imageUrls);
|
162 |
setLoadingImages([]);
|
|
|
136 |
});
|
137 |
}, updateInterval);
|
138 |
|
139 |
+
const response = await fetch("/api/v1/images/generate", {
|
140 |
method: "POST",
|
141 |
headers: {
|
142 |
"Content-Type": "application/json",
|
|
|
156 |
if (data.success && (data.filenames || data.filename)) {
|
157 |
const filenames = data.filenames || (data.filename ? [data.filename] : []);
|
158 |
const imageUrls = filenames.map(filename =>
|
159 |
+
`/api/v1/images/download/${filename}`
|
160 |
);
|
161 |
setGeneratedImages(imageUrls);
|
162 |
setLoadingImages([]);
|
backend/app/main.py
CHANGED
@@ -44,6 +44,9 @@ def create_app() -> FastAPI:
|
|
44 |
"http://127.0.0.1:3000",
|
45 |
"http://localhost:8000",
|
46 |
"http://127.0.0.1:8000",
|
|
|
|
|
|
|
47 |
],
|
48 |
allow_credentials=True,
|
49 |
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
@@ -52,7 +55,7 @@ def create_app() -> FastAPI:
|
|
52 |
|
53 |
app.add_middleware(
|
54 |
TrustedHostMiddleware,
|
55 |
-
allowed_hosts=["localhost", "127.0.0.1", "0.0.0.0"],
|
56 |
)
|
57 |
|
58 |
return app
|
@@ -61,5 +64,10 @@ def create_app() -> FastAPI:
|
|
61 |
app = create_app()
|
62 |
|
63 |
|
|
|
|
|
|
|
|
|
|
|
64 |
# Include API router
|
65 |
app.include_router(api_router, prefix=settings.API_V1_STR)
|
|
|
44 |
"http://127.0.0.1:3000",
|
45 |
"http://localhost:8000",
|
46 |
"http://127.0.0.1:8000",
|
47 |
+
"https://*.hf.space",
|
48 |
+
"https://*.huggingface.co",
|
49 |
+
"*" # Allow all origins for Hugging Face deployment
|
50 |
],
|
51 |
allow_credentials=True,
|
52 |
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
|
55 |
|
56 |
app.add_middleware(
|
57 |
TrustedHostMiddleware,
|
58 |
+
allowed_hosts=["localhost", "127.0.0.1", "0.0.0.0", "*"],
|
59 |
)
|
60 |
|
61 |
return app
|
|
|
64 |
app = create_app()
|
65 |
|
66 |
|
67 |
+
# Health check endpoint
|
68 |
+
@app.get("/health")
|
69 |
+
async def health_check():
|
70 |
+
return {"status": "healthy", "message": "Backend is running"}
|
71 |
+
|
72 |
# Include API router
|
73 |
app.include_router(api_router, prefix=settings.API_V1_STR)
|
backend/requirements.txt
CHANGED
@@ -2,4 +2,5 @@ fastapi==0.104.1
|
|
2 |
uvicorn[standard]==0.24.0
|
3 |
pydantic==2.5.0
|
4 |
pydantic-settings==2.1.0
|
5 |
-
openai==1.82.0
|
|
|
|
2 |
uvicorn[standard]==0.24.0
|
3 |
pydantic==2.5.0
|
4 |
pydantic-settings==2.1.0
|
5 |
+
openai==1.82.0
|
6 |
+
python-dotenv==1.0.0
|
next.config.ts
CHANGED
@@ -3,6 +3,7 @@ import type { NextConfig } from "next";
|
|
3 |
const nextConfig: NextConfig = {
|
4 |
output: "standalone",
|
5 |
images: {
|
|
|
6 |
remotePatterns: [
|
7 |
{
|
8 |
protocol: 'http',
|
@@ -16,6 +17,11 @@ const nextConfig: NextConfig = {
|
|
16 |
port: '8000',
|
17 |
pathname: '/api/v1/images/download/**',
|
18 |
},
|
|
|
|
|
|
|
|
|
|
|
19 |
],
|
20 |
},
|
21 |
rewrites: async () => {
|
@@ -25,7 +31,7 @@ const nextConfig: NextConfig = {
|
|
25 |
destination:
|
26 |
process.env.NODE_ENV === "development"
|
27 |
? "http://localhost:8000/api/:path*"
|
28 |
-
: "/api
|
29 |
},
|
30 |
];
|
31 |
},
|
|
|
3 |
const nextConfig: NextConfig = {
|
4 |
output: "standalone",
|
5 |
images: {
|
6 |
+
domains: ['localhost', '127.0.0.1'],
|
7 |
remotePatterns: [
|
8 |
{
|
9 |
protocol: 'http',
|
|
|
17 |
port: '8000',
|
18 |
pathname: '/api/v1/images/download/**',
|
19 |
},
|
20 |
+
{
|
21 |
+
protocol: 'http',
|
22 |
+
hostname: '*',
|
23 |
+
pathname: '/api/v1/images/download/**',
|
24 |
+
},
|
25 |
],
|
26 |
},
|
27 |
rewrites: async () => {
|
|
|
31 |
destination:
|
32 |
process.env.NODE_ENV === "development"
|
33 |
? "http://localhost:8000/api/:path*"
|
34 |
+
: "http://localhost:8000/api/:path*",
|
35 |
},
|
36 |
];
|
37 |
},
|