wails
wails copied to clipboard
MacOS HTMX polling fails
Description
Whenever I use HTMX polling, only the first request is received by Go and the rest won't even show up in inspector's network. This works on all major browsers using wails exposed http interface though. Enabling HTMX logs via htmx.logAll() shows the XHR and other HTMX events caused by the polling, yet only one network request is made.
To Reproduce
- On MacOS, create a basic wails project
wails init -n htmx-test -t vanilla - Import HTMX script in
frontend/index.html
<script src="https://unpkg.com/[email protected]"></script>
- Add an HTMX element with polling:
<div hx-get="/now" hx-trigger="load, every 1s"></div>
- Use an HTTP middleware for wails asset server. I used echo:
func main() {
app := NewApp()
e := echo.New()
e.GET("/now", func(c echo.Context) error {
return c.String(http.StatusOK, time.Now().Format(time.TimeOnly))
})
err := wails.Run(&options.App{
Title: "test",
Width: 1024,
Height: 768,
AssetServer: &assetserver.Options{
Assets: assets,
Middleware: func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
for _, route := range e.Routes() {
if route.Path == r.URL.Path {
e.ServeHTTP(w, r)
return
}
}
next.ServeHTTP(w, r)
})
},
},
})
if err != nil {
println("Error:", err.Error())
}
}
- Run
wails devand you will get single request to/now
Expected behaviour
HTMX polling to successfully send requests
Screenshots
No response
Attempted Fixes
No response
System Details
MBP M1 2020 16GB
MacOS 14 Sonoma
Additional context
No response