🐛 [Bug]: Routing - static route broken by route with param
Bug Description
Route with parameter impacting static routes with parameters.
fiberServ.Static("/", "./public") **// OK**
fiberServ.Static("/", "./public") **// OK**
fiberServ.Get("/home", app.HomeHandler) **// OK**
fiberServ.Static("/", "./public") // BROKEN
**fiberServ.Get("/entity/:uid", app.EntityHandler) // Breaks static routes!**
fiberServ.Get("/home", app.HomeHandler) // OK
How to Reproduce
Steps to reproduce the behavior:
-
Server with the following routes
fiberServ.Static("/", "./public") fiberServ.Get("/entity/:uid", app.EntityHandler) fiberServ.Get("/home", app.HomeHandler)
-
Accessing route /entity/123456789 breaks static routes, adding /entity/ to the static paths.
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8000/entity/css/bulma.min.css
-
This incorrect behavior does NOT happen with non-parameterized routes like /home. In this case the style sheet in /public/css/bulma.min.css is served properly.
-
Using a prefix for static does NOT solve the problem. Neither does a trailing / or . fiberServ.Static("/public", "./public") fiberServ.Static("/public/", "./public") fiberServ.Static("/", "./public")
Expected Behavior
So-called regular, with params, routes should not alter static route.
Fiber Version
ithub.com/gofiber/fiber/v2 v2.52.5
Code Snippet (optional)
package main
import "github.com/gofiber/fiber/v3"
import "log"
func main() {
app := fiber.New()
// Steps to reproduce
log.Fatal(app.Listen(":3000"))
}
Checklist:
- [X] I agree to follow Fiber's Code of Conduct.
- [X] I have checked for existing issues that describe my problem prior to opening this one.
- [X] I understand that improperly formatted bug reports may be closed without explanation.
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
@darsenault Can you provide a small reproducible example. Thanks
Is this still an issue ? @darsenault Could you also provide a small reproducible example so I can take a look at this one. Thanks