mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 10:55:27 +00:00
chore(web): revert apps/web/src/index.ts changes
This commit is contained in:
+9
-21
@@ -9,8 +9,6 @@ import { metadataService } from '@shumai/core/src/metadata/metadata'
|
||||
import { initTranscodeWorkflows } from '@shumai/transcode'
|
||||
import { workflowService } from '@shumai/workflow-core'
|
||||
import { app } from '@shumai/api'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
|
||||
// Initialize workflows and activities for local executor mode
|
||||
initAgentWorkflows()
|
||||
@@ -45,27 +43,17 @@ if (process.env.WORKFLOW_EXECUTOR === 'temporal') {
|
||||
|
||||
const server = Bun.serve({
|
||||
port: 3000,
|
||||
async fetch(req) {
|
||||
const url = new URL(req.url)
|
||||
const pathname = url.pathname
|
||||
fetch: app.fetch,
|
||||
routes: {
|
||||
// Serve index.html for root
|
||||
'/': index,
|
||||
|
||||
if (pathname.startsWith('/api/') || pathname.startsWith('/files/')) {
|
||||
return app.fetch(req)
|
||||
}
|
||||
// Proxy API requests to Hono
|
||||
'/api/*': app.fetch,
|
||||
'/files/*': app.fetch,
|
||||
|
||||
// Try serving from public folder
|
||||
let publicFilePath = ''
|
||||
if (pathname.startsWith('/public/')) {
|
||||
publicFilePath = path.join(process.cwd(), 'packages/webui/public', pathname.substring(8))
|
||||
} else {
|
||||
publicFilePath = path.join(process.cwd(), 'packages/webui/public', pathname)
|
||||
}
|
||||
|
||||
if (fs.existsSync(publicFilePath) && fs.statSync(publicFilePath).isFile()) {
|
||||
return new Response(Bun.file(publicFilePath))
|
||||
}
|
||||
|
||||
return new Response(index as unknown as BodyInit)
|
||||
// Catch-all for SPA routing (fallback to index.html)
|
||||
'/*': index,
|
||||
},
|
||||
development: process.env.NODE_ENV !== 'production',
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user