Repository navigation
plugins/static #587
Replies: 6 comments 8 replies
|
Can I have the static pluging serve content for the site root? |
|
Seems this plugin doesn't work for newly uploaded files, |
🦊 Elysia is running at localhost:3002
164 | if (shouldIgnore(pathName)) throw new NotFoundError();
165 | const cache = fileCache.get(pathName);
166 | if (cache) return cache.clone();
167 | try {
168 | const fileStat = await fs.stat(pathName).catch(() => null);
169 | if (!fileStat) throw new NotFoundError();
^
error: NOT_FOUND
status: 404,
code: "NOT_FOUND"
at <anonymous> (/Users/macbookpro/Documents/project/monorepo/sci-master/node_modules/.pnpm/@elysiajs+static@1.4.7_elysia@1.4.22_@sinclair+typebox@0.34.48_exact-mirror@0.2.6_@sinc_894428d145c519d7fe4e3799772fabe9/node_modules/@elysiajs/static/dist/index.mjs:169:32)
at async handle (file:///Users/macbookpro/Documents/project/monorepo/sci-master/node_modules/.pnpm/elysia@1.4.22_@sinclair+typebox@0.34.48_exact-mirror@0.2.6_@sinclair+typebox@0.34.48__f_22fc0dc8ac9c2b02f26b937f6751f981/node_modules/elysia/dist/bun/index.js:7:37)does anyone have any suggestions? new Elysia().use(staticPlugin({ prefix: "/" }))i can display image but server give that log and the url cannot display with another website, like i need display in my nextjs website and give 400 error code I'm still in development mode, if development mode is like this i am not sure about production mode |
|
How i config for a SPA ? We konw bun can do that: Single Page Apps (SPA) bun index.html |
|
In latest bun/elysia/static plugin versions you need to add import { staticPlugin } from "@elysiajs/static"
import { Elysia } from "elysia"
export const tools = new Elysia()
.get("/", ({ redirect }) => redirect("/tools", 302))
.use(
staticPlugin({
// URL where app is hosted by Elysia
prefix: "/tools",
// path location to the app source folder
assets: "src/frontend/",
// new option for latest bun and Elysia Static plugin
// Use bun bundler to package SPA app on the fly
bunFullstack: true,
}),
) |
|
When i try to fetch a file/image from a docker container, it returns a 404 error. |
Uh oh!
There was an error while loading. Please reload this page.
plugins/static
Plugin for Elysia that adds support for serving static files/folders for Elysia Server. Start by installing the plugin with "bun add @elysiajs/static".
https://elysiajs.com/plugins/static
All reactions