ui integration and rest api includes

This commit is contained in:
2026-05-20 15:34:41 +05:30
parent f4dc2b6a5a
commit 349d152b76
18 changed files with 3631 additions and 589 deletions

View File

@@ -19,7 +19,8 @@ import 'dotenv/config'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const PORT = Number(process.env.PORT) || 3000
const SECRET = (process.env.HASURA_ADMIN_SECRET || '').trim()
const TARGET = 'https://api.workolik.com'
const TARGET_LEGACY = 'https://api.workolik.com'
const TARGET_REST = 'https://fiesta.nearle.app'
if (!SECRET) {
console.warn('[xpress-docs] WARNING: HASURA_ADMIN_SECRET is not set. Proxied API calls will be sent without auth.')
@@ -27,13 +28,9 @@ if (!SECRET) {
const app = express()
app.use('/api', createProxyMiddleware({
target: TARGET,
const commonProxyOptions = {
changeOrigin: true,
secure: true,
// The mount strips '/api' from req.url; add it back so the target URL
// stays /api/rest/...
pathRewrite: (p) => '/api' + p,
on: {
proxyReq: (proxyReq) => {
if (SECRET) proxyReq.setHeader('x-hasura-admin-secret', SECRET)
@@ -46,6 +43,18 @@ app.use('/api', createProxyMiddleware({
res.end(JSON.stringify({ error: 'proxy_error', message: err.message }))
}
}
}
app.use('/api', createProxyMiddleware({
...commonProxyOptions,
target: TARGET_LEGACY,
pathRewrite: (p) => '/api' + p
}))
app.use('/live', createProxyMiddleware({
...commonProxyOptions,
target: TARGET_REST,
pathRewrite: (p) => '/live' + p
}))
// Built React app
@@ -57,6 +66,7 @@ app.get('*', (_req, res) => {
app.listen(PORT, () => {
console.log(`[xpress-docs] listening on http://localhost:${PORT}`)
console.log(`[xpress-docs] proxying /api/* -> ${TARGET}/api/*`)
console.log(`[xpress-docs] proxying /api/* -> ${TARGET_LEGACY}/api/*`)
console.log(`[xpress-docs] proxying /live/* -> ${TARGET_REST}/live/*`)
console.log(`[xpress-docs] admin secret: ${SECRET ? 'loaded' : 'NOT SET'}`)
})