Open Chooks22 opened 7 months ago
I'm experiencing the same problem when using @elysiajs/html
with @elysiajs/static
. As a temporary workaround, I created an assets endpoint with a wildcard and use Bun.file to retrieve them.
//index.jsx
import { Elysia, t } from 'elysia';
import { html } from "@elysiajs/html";
new Elysia()
.use(html())
.get('/assets/*', ({ set, params }) => {
const file = Bun.file(`${import.meta.dir}/assets/${params['*']}`);
set.headers['Content-Type'] = file.type;
return file.text();
})
.get('/', () => {
return (
<html lang='en'>
<head>
<script src="assets/js/htmx.min.js" />
</head>
<body>
<form hx-post="/" hx-swap="afterend">
<input type="text" name="name" />
<button type='submit'>Click Me!</button>
</form>
</body>
</html>
)
})
.post('/', ({ body }) => {
return (<script>alert("{body.name}!")</script>);
}, {
body: t.Object({ name: t.String() })
})
.listen(9999, ({ port }) => {
console.log(`Server is running on port ${port}`)
});
But I think the segmentation fault is related to Bun.
What version of Elysia.JS is running?
1.0.0-beta.14
What platform is your computer?
Linux 6.7.9-zen1-1-zen x86_64 unknown
What steps can reproduce the bug?
What is the expected behavior?
What do you see instead?
Additional information
Same issue on v0.8.x of Elysia Adding
--watch
or--hot
flags tobun run
works around the issue