Skip to content

Commit 755d04f

Browse files
committed
add metadata routes
1 parent 06fc236 commit 755d04f

File tree

4 files changed

+297
-265
lines changed

4 files changed

+297
-265
lines changed

MyApp.Client/lib/gateway.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { appendQueryString, nameOf, IReturn, JsonServiceClient } from "@servicestack/client"
22
import useSWR from "swr"
33
import { Authenticate } from "@/lib/dtos"
4-
import { useMetadata } from "@servicestack/react"
54

65
const serverRoutePaths = [
76
'/Identity',
7+
'/metadata',
88
'/api',
99
'/ui',
1010
'/chat',
@@ -13,7 +13,7 @@ const serverRoutePaths = [
1313
'/scalar',
1414
]
1515

16-
export function isServerRoute(path:string) {
16+
export function isServerRoute(path: string) {
1717
return serverRoutePaths.some(x => path.startsWith(x))
1818
}
1919

@@ -23,7 +23,6 @@ export const Routes = {
2323
}
2424

2525
export const client = new JsonServiceClient()
26-
export const metadata = useMetadata(client)
2726

2827
// Load Metadata & Auth State on Startup
2928
// This needs to be called on client side only
@@ -40,8 +39,8 @@ export async function init() {
4039
.then(r => {
4140
authCtx.signIn(r)
4241
}).catch(() => {
43-
authCtx.signOut()
44-
})
42+
authCtx.signOut()
43+
})
4544
])
4645
}
4746

MyApp.Client/next.config.mjs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const isProd = process.env.NODE_ENV === 'production'
77
const buildLocal = process.env.MODE === 'local'
88

99
// Define DEPLOY_API first
10-
const DEPLOY_API = process.env.KAMAL_DEPLOY_HOST
11-
? `https://${process.env.KAMAL_DEPLOY_HOST}`
10+
const DEPLOY_API = process.env.KAMAL_DEPLOY_HOST
11+
? `https://${process.env.KAMAL_DEPLOY_HOST}`
1212
: target
1313

1414
// Now use it for API_URL
@@ -30,6 +30,23 @@ const nextConfig = {
3030
env: {
3131
apiBaseUrl: API_URL
3232
},
33+
34+
// Proxy API requests to backend during development
35+
async rewrites() {
36+
// Only proxy in development mode
37+
if (isProd) return []
38+
39+
return [
40+
{
41+
source: '/api/:path*',
42+
destination: `${target}/api/:path*`,
43+
},
44+
{
45+
source: '/metadata/:path*',
46+
destination: `${target}/metadata/:path*`,
47+
},
48+
]
49+
},
3350
}
3451

3552
const withMDX = createMDX({

0 commit comments

Comments
 (0)