Skip to content

🐞 app.Static serving index.html as text/plain  #420

@soulchainer

Description

@soulchainer

Using Fiber v1.10.1

Question description

I'm not sure if this is a bug or I understood it wrong.
It seems the root route must be defined first of all routes, otherwise its content will be rendered as plain text.

Code snippet (optional)

This will result in index.html, at /, being rendered as text/plain:

package main

import "github.com/gofiber/fiber"

func main() {
  app := fiber.New()

  app.Static("/otherPath", otherPath) // I'm using here an absolute path
  app.Static("/", "./public")

  app.Listen(8000)
}

This will result in index.html, at /, being rendered as text/html:

package main

import "github.com/gofiber/fiber"

func main() {
  app := fiber.New()

  app.Static("/", "./public")
  app.Static("/otherPath", otherPath)

  app.Listen(8000)
}

Of course, this is not a big deal. It's customary to put the root first most of the time, but even so I just don't know, is this intended behavior or...?

Thanks for your time!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions