Skip to content

Latest FS improvement breaks static routes #2117

Closed
@heat1q

Description

@heat1q

Issue Description

It appears that the file system improvement (#2064) in the latest release v4.7.0 is breaking the backwards compatibility of static routes. Files that are registered with the Static method are no longer served on that route and a 404 is returned. This issue has already been briefly mentioned in the comments of #2064. I'd like to continue the discussion on this issue here and give a short example.

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

The Static method should work and files should be served the same as with <=4.6.3. In other words, the minor update should not change the behaviour of the Static method.

Actual behaviour

Static file routes registered with Static are not serving the given files when updating to echo v4.7.0.

Steps to reproduce

  1. Create a file in the main directory, eg. index.html
  2. Run the code below with echo v4.6.3
  3. curl http://localhost:8080 -v ==> 200 OK
  4. Run the code with echo v4.7.0
  5. curl http://localhost:8080 -v ==> 404 Not found

Working code to debug

.
├── go.mod
├── go.sum
├── index.html
└── main.go
// main.go
package main

import (
	"github.com/labstack/echo/v4"
)

func main() {
	e := echo.New()
	e.Static("", "./index.html")
	e.Logger.Fatal(e.Start(":8080"))
}

Version/commit

go version go1.17.6 darwin/arm64
echo v4.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions