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's prefix: '/' breaks elysia's mount() #30

Open
yuniruyuni opened this issue Jun 23, 2024 · 0 comments
Open

staticPlugin's prefix: '/' breaks elysia's mount() #30

yuniruyuni opened this issue Jun 23, 2024 · 0 comments

Comments

@yuniruyuni
Copy link

yuniruyuni commented Jun 23, 2024

What happen?

When you are using staticPlugin({prefix: '/'}) with mount() method,
Your fetch function faces req.url argument will rewrited as / all times.

Reproduction code

reproduction.ts

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

const app = new Elysia();

app.mount("/test/", async (req) =>{
        console.log(req.url);
        return new Response("test");
    });

app.use(staticPlugin({ prefix: "/" }));

export default {
    port: 3000,
    fetch: app.fetch,
};

run bun run reproduction.ts
and access http://localhost:3000/test/hogehoge.js or http://localhost:3000/test/fugafuga.png something so on,
then you will see the output is http://localhost:3000/ instead of expected http://localhost:3000/hogehoge.js or http://localhost:3000/fugafuga.png.

Environment

  • Linux 6.9.3-3
  • bun 1.1.15
  • elysia 1.0.25
  • @elysiajs/static 1.0.3
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

1 participant