Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staticPlugin response NOT_FOUND #739

Open
goodlythink opened this issue Jul 19, 2024 · 9 comments
Open

staticPlugin response NOT_FOUND #739

goodlythink opened this issue Jul 19, 2024 · 9 comments

Comments

@goodlythink
Copy link

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

  • public
    • student.png
  • src
    • index.ts

when run on browser
http://localhost:3000/public/student.png

browser display NOT_FOUND

how to fix

image

image

Originally posted by @goodlythink in #735

@devara-gheist
Copy link

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:

  • root
    • public
      • copy.js
    • src
      • db
        • schema.ts
      • index.ts
      • index.html

image

Below is index.html:
image

when I run the app using bun dev:
image

Please kindly advise, cheers!

@goodlythink
Copy link
Author

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

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

kravetsone added a commit to kravetsone/elysia-remix that referenced this issue Jul 20, 2024
@crishoj
Copy link
Contributor

crishoj commented Sep 4, 2024

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
Copy link

what's you elysia version?

@crishoj
Copy link
Contributor

crishoj commented Sep 9, 2024

Elysia 1.1.11 and @elysiajs/static 1.1.0.

@nichenqin
Copy link

Elysia 1.1.11 and @elysiajs/static 1.1.0.

I found the issue gone when I downgrade elysia to 1.1.7

@crishoj
Copy link
Contributor

crishoj commented Sep 9, 2024

I found the issue gone when I downgrade elysia to 1.1.7

Thanks. Will keep this option in mind.

@nachat-ayoub
Copy link

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.

@crishoj
Copy link
Contributor

crishoj commented Oct 22, 2024

staticPlugin 1.1.1 still fails with Elysia 1.1.23 here:

HTTP GET /public/assets/js/Components-Lh061ZJU.js : Error NOT_FOUND

Ubuntu 23.10 (x86_64) with Bun 1.1.32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants