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

[IMPORTANT] [BUG] indexHTML option is broken in latest version #37

Closed
touhidurrr opened this issue Oct 10, 2024 · 4 comments · Fixed by #40
Closed

[IMPORTANT] [BUG] indexHTML option is broken in latest version #37

touhidurrr opened this issue Oct 10, 2024 · 4 comments · Fixed by #40

Comments

@touhidurrr
Copy link

touhidurrr commented Oct 10, 2024

Important

This bug only appears when NODE_ENV=production

Folder structure

| - public
  | - index.html
  | - test
    | - index.html
| - test.ts

Files

index.html -> fill in with any generic HTML content.

// test.ts
import { Elysia } from 'elysia';
import { staticPlugin } from '@elysiajs/static';

const port = 8080;
const hostname = '0.0.0.0';

const app = new Elysia()
  .use(staticPlugin({ prefix: '/', indexHTML: true }))
  .listen({ port, hostname });

console.log(`Server started at ${app.server?.url}`);

Note

indexHTML is true by default, but I set it to true explicitly anyways

Versions

  1. Bun -> 1.1.31
  2. elysia -> 1.1.20
  3. @elysiajs/static -> 1.1.1

Tests

  1. GET http://localhost:8080/ -> (redirect) http://localhost:8080 -> NOT_FOUND
  2. GET http://localhost:8080 -> NOT_FOUND
  3. GET http://localhost:8080/test -> NOT_FOUND
  4. GET http://localhost:8080/test/ -> NOT_FOUND
  5. GET http://localhost:8080/index.html -> Works
  6. GET http://localhost:8080/test/index.html -> Works

Conclusion

indexHTML option in all broken in all shape and form is the latest version. After some testing, the last working version is 1.0.3.

@touhidurrr touhidurrr changed the title [IMPORTANT] [BUG] indexHTML option is broken static plugin latest version [IMPORTANT] [BUG] indexHTML option is broken in latest version Oct 10, 2024
@RafalGoslawski
Copy link
Contributor

I've ran into this issue just now, and setting alwaysStatic: false, seems to fix it for me. I didn't dig any deeper yet.

@touhidurrr
Copy link
Author

@RafalGoslawski, it is frustrating how long we have to wait for a simple bug to be fixed even after we have reported in and opened a pr in elysia. This is sad.
More that one and a half months have passed since I open this pr.

@touhidurrr
Copy link
Author

And this is not a normal bug at all. This breaks my homepage.

@RafalGoslawski
Copy link
Contributor

@touhidurrr I get the frustration. There's always a risk when it comes to using software that's a personal project (i.e. maintained by 1 person). That being said, we're paying nothing to use this software so the author has no obligation to us.

It's MIT licensed, so you can make your own fork with the patches you need and use that. Or even simpler, use bun patch in your project and just subscribe to this issue to see if it eventually gets patched upstream and you no longer need a workaround.

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