Skip to content

Commit

Permalink
fix: support single page application routing
Browse files Browse the repository at this point in the history
  • Loading branch information
ikxin committed Apr 17, 2024
1 parent 621aff3 commit f65c123
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions service/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { Elysia } from 'elysia'
import { staticPlugin } from '@elysiajs/static'

new Elysia()
// .use(
// staticPlugin({
// assets: 'dist/assets',
// prefix: '/assets',
// }),
// )
// .get('/*', () => Bun.file('dist/index.html'))
.onError(ctx => {
if (ctx.code === 'NOT_FOUND') {
ctx.set.redirect = '/'
return ''
}
})
.use(staticPlugin({ assets: 'dist', prefix: '/' }))
.get('/', () => Bun.file('dist/index.html'))
.listen(3000)
const app = new Elysia()

app.use(
staticPlugin({
assets: 'dist/assets',
prefix: '/assets',
}),
)

app.get('/*', () => Bun.file('dist/index.html'))

app.listen(3000)

0 comments on commit f65c123

Please sign in to comment.