echo icon indicating copy to clipboard operation
echo copied to clipboard

Statics Files not working on macOS but Windows

Open vuxt opened this issue 4 years ago • 2 comments

Issue Description

This snippet code work fine on Windows 10 Screen Shot 2020-09-19 at 13 45 14 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:

  1. macOs 10.14.6
  2. go version go1.15.2 darwin/amd64

Step:

  1. go build
  2. 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

vuxt avatar Sep 19 '20 06:09 vuxt

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

yusufsyaifudin avatar Oct 01 '20 02:10 yusufsyaifudin

@vuxt, Did you had time to check @yusufsyaifudin comment? I tried myself and it's working for me

pafuent avatar Jun 06 '21 03:06 pafuent