Skip to content

🐛 [Bug]: When mounting a subapp with mount, the static route is inaccessible. #3442

@hiifong

Description

@hiifong

Bug Description

as title.
Image

How to Reproduce

package main

import (
	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/internal/template/html"
)

func main() {
	app := fiber.New(fiber.Config{
		Views: html.New("./example/views", ".html"),
	})

	app.Static("/static", "./example/static", fiber.Static{
		Browse: true,
		Index:  "",
	})
	app.Get("/", func(c *fiber.Ctx) error {
		return c.SendString("Home")
	})

	app1 := fiber.New()
	app.Mount("/mount", app1)
	app.Route("/:name", func(r fiber.Router) {
		r.Get("", func(c *fiber.Ctx) error {
			return c.SendString("Hello, World --> " + c.Params("name"))
		})
	})

	app.Use(func(c *fiber.Ctx) error {
		return c.Status(fiber.StatusNotFound).SendString("Not Found")
	})

	app.Listen(":9191")
}

Expected Behavior

This static resource can be accessed.

Fiber Version

v2.52.6

Code Snippet (optional)

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my problem prior to opening this one.
  • I understand that improperly formatted bug reports may be closed without explanation.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions