Skip to content

Absolute paths in c.File don't work anymore #2922

Closed

Description

@zoriya

Hey, when trying to update to v5 we encountered a bug where all absolute paths would return a NotFound instead of the proper path of the file. This is the same bug as #2117 that was fixed with #2123 but looking at the code, this fix doesn't exist anymore.

Activity

  1. aldas commented on Mar 21, 2026

    @aldas
    Contributor

    in v5 e.Filesystem is confined to current working directory
    If you want to have similar behaviour like v4 did you need to do

    e.Filesystem = os.DirFS("/")
  2. zoriya commented on Mar 21, 2026

    @zoriya
    Author

    That still doesn't work for absolute paths. c.File("/dir/my-file.txt") will return a NotFound but c.File("dir/my-file.txt") will work.

  3. aldas commented on Mar 29, 2026

    @aldas
    Contributor

    I'll update the website and the relevant field/function documentation to clarify that leading / slashes should not be used. In v5 this aligns better how modern Go fs.FS implementations behave, and Echo v4 was using/mirroring os.Open, which is now little bit disfavored when it comes to serving files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions