go-app: TypeError: WebAssembly: Response has unsupported MIME type 'text/plain; charset=utf-8' expected 'application/wasm'

Getting this error

TypeError: WebAssembly: Response has unsupported MIME type 'text/plain; charset=utf-8' expected 'application/wasm'
package ui

import "github.com/maxence-charriere/go-app/v9/pkg/app"

type Home struct {
	app.Compo
}

func (h *Home) Render() app.UI {
	return app.Html().Body(
		app.Head().Body(
			app.Meta().Name("charset").Content("utf-8"),
		),
		app.Body().Body(
			app.H1().Text("Hello World"),
		),
	)

}
package cmd

import (
	"net/http"

	"mypackagepath/ui"
	"github.com/maxence-charriere/go-app/v9/pkg/app"
	"github.com/spf13/cobra"
)

// uiCmd represents the ui command
var uiCmd = &cobra.Command{
	Use:   "ui",
	Short: "",
	RunE: func(cmd *cobra.Command, args []string) error {
		app.Route("/", new(ui.Home))
		app.RunWhenOnBrowser()
		http.Handle("/", &app.Handler{
			Author:       "A name",
			Description:  "domain.tld is an URL shortener service",
			LoadingLabel: "Yo! Wait up, it's loading...",
			Name:         "Some Name",
			Title:        "domain.tld - shorturl service",
			Version:      "1",
		})

		return http.ListenAndServe(":7890", nil)
	},
}

func init() {
	rootCmd.AddCommand(uiCmd)
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (11 by maintainers)

Most upvoted comments

I just did a cd in the script that launches it. All good, that was it. Thanks for talking me through it!

But… having this kind of subdomain actually prevents one of Go-App’s main functionality: Installation as an App on the user’s phone or desktop. Which is the only reason for us to use it. Loading such a large Wasm code every time I open the app again does not make sense 😃. So, I wonder why you want to use Go-App for that use case?

There is also https://github.com/mlctrez/goappcreate by @mlctrez which uses another approach (the usual make instead of mage and gin framework instead of the chi router). I do not have our “watcher” included in my first example (the reloading because that’s a lot of proprietary code now). In the go-nats-app there is also the back- and front end communication solved. But it is using NATS for that, which is a very cool and powerful but unusual approach. Before that, we were using “Twirp” and a bit web sockets and standard REST. The NATS combines this and makes stuff effortless to write and understand.