-
-
Notifications
You must be signed in to change notification settings - Fork 357
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Elysia is running?
1.2.25
What platform is your computer?
Linux 5.10.240-238.966.amzn2.x86_64 x86_64 unknown (from oven/bun:1.2.19 Docker image)
What environment are you using
1.2.19
Are you using dynamic mode?
no
What steps can reproduce the bug?
Here's the relevant code from that path
const app = new Elysia({
serve: {
idleTimeout: 60,
},
})
.all("/healthz", healthz)
.use(elysiaLogger("api"))
.use(errorHandler())
.use(isAxiomEnabled() ? elysiaTelemetry(SERVICE_NAME) : new Elysia())
.use(
cors({
origin: [
"https://domain.com",
"https://another.com",
"https://test.domain.com",
"https://admin.domain.com"
].filter(Boolean),
}),
)
.use(v1Routes)
.use(webhookRoutes)
.use(internalRoutes)
// Serve the static frontend. These routes must come last.
.use(frontendRoutes)
.listen(process.env.PORT ?? 8000);
export const frontendRoutes = new Elysia()
.get("/*", async ({ params }) => {
return serveFile(params["*"]);
});
async function serveFile(path: string) {
try {
const safePath = normalize(path);
const fullPath = join(BASE_DIR, safePath);
if (existsSync(fullPath) && statSync(fullPath).isFile()) {
return file(fullPath);
}
What is the expected behavior?
CORS headers should be applied to the files served
What do you see instead?
No CORS headers added
Additional information
Our current, working, workaround is to take the ElysiaFile and build a normal Response
object, taking the file contents as the body. When doing this, the CORS headers are being applied correctly.
Have you try removing the node_modules
and bun.lockb
and try again yet?
Yes
Rouret
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working