echo
echo copied to clipboard
Statics Files not working on macOS but Windows
Issue Description
This snippet code work fine on Windows 10
but when I run on macOS, it display {"message":"Not Found"} with console log "GET http://localhost:1323/ 404 (Not Found)".
/ping work well in both case.
Checklist
- [x] Dependencies installed
- [x] No typos
- [x] Searched existing issues and docs
Expected behaviour
Serving an index.html file
Actual behaviour
Display {"message":"Not Found"}
Steps to reproduce
Environment:
- macOs 10.14.6
- go version go1.15.2 darwin/amd64
Step:
- go build
- Run
Working code to debug
package main
import (
"context"
"fmt"
"net/http"
"os"
"os/signal"
"time"
"github.com/labstack/echo/v4"
)
func main() {
e := echo.New()
e.GET("/ping", func(c echo.Context) error {
return c.String(http.StatusOK, "poong\n")
})
e.File("/", "public/index.html")
go func() {
if err := e.Start(":1323"); err != nil {
e.Logger.Info("SHUTTING DOWN THE SERVER")
}
}()
quit := make(chan os.Signal)
signal.Notify(quit, os.Interrupt)
<-quit
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if err := e.Shutdown(ctx); err != nil {
e.Logger.Fatal(err)
}
fmt.Println("SHUT DOWN THE SERVER!")
}
Version/commit
v4.1.17
Hi @vuxt I am reproducing your code in my mac and it works just fine. Ensure that you run your binary or your program in same directory as your public/index.html
located. The tree directory that I use is something like this:
- main.go
- public
- index.html
Then I run my program with go run main.go
@vuxt, Did you had time to check @yusufsyaifudin comment? I tried myself and it's working for me