elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
10.25k stars 219 forks source link

staticPlugin response NOT_FOUND #739

Open goodlythink opened 3 months ago

goodlythink commented 3 months ago

I have tried following the example.

import { Elysia } from 'elysia'
import { staticPlugin } from '@elysiajs/static'

new Elysia()
    .use(staticPlugin())
    .get("/", () => "Hello World!")
    .listen(3000)

and my folder structure

browser display NOT_FOUND

how to fix

image

image

Originally posted by @goodlythink in https://github.com/elysiajs/elysia/discussions/735

devara-gheist commented 2 months ago

i'm getting a similar issue with staticPlugin, the difference is I'm trying to import a JS file from the public directory.

My project structure:

image

Below is index.html: image

when I run the app using bun dev: image

Please kindly advise, cheers!

goodlythink commented 2 months ago

i found. if set option noCach: true it's can serve static files

.use(staticPlugin({ noCache: true }))

crishoj commented 1 month ago

Also suddenly seeing this.

HTTP GET /public/assets/index-CME56wGF.css {} : Error NOT_FOUND
HTTP GET /public/assets/index-EYdG_EqJ.js {} : Error NOT_FOUND

Config:

new Elysia()
  .get('/', () => Bun.file('public/index.html'))
  .use(staticPlugin())

Files are present:

public/
├── assets
│   ├── Components-BttXgYS5.js
│   ├── Events-DD2it1Vn.js
│   ├── index-CME56wGF.css
│   └── index-EYdG_EqJ.js
├── favicon.ico
├── index.html
└── logo.png

The { noCache: true } fix doesn't work for me.

nichenqin commented 1 month ago

what's you elysia version?

crishoj commented 1 month ago

Elysia 1.1.11 and @elysiajs/static 1.1.0.

nichenqin commented 1 month ago

Elysia 1.1.11 and @elysiajs/static 1.1.0.

I found the issue gone when I downgrade elysia to 1.1.7

crishoj commented 1 month ago

I found the issue gone when I downgrade elysia to 1.1.7

Thanks. Will keep this option in mind.

nachat-ayoub commented 3 weeks ago

i am on elysia latest version 1.1.13. the problem gone after i renamed the public files and replaced all spaces in the files names with another character. the Space character in the files names was giving this error for me.