Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing nested directories #148

Open
bmw2621 opened this issue Jun 16, 2021 · 2 comments
Open

Accessing nested directories #148

bmw2621 opened this issue Jun 16, 2021 · 2 comments

Comments

@bmw2621
Copy link

bmw2621 commented Jun 16, 2021

I am attempting to serve a Svelte site, and used the counter example as a starting point. I am able to use the development server with

ui.Load("http://localhost:5000")

but when I want to serve the static built files:

//go:embed frontend/public
var publicFolder embed.FS

...

go http.Serve(ln, http.FileServer(http.FS(publicFolder)))
ui.Load(fmt.Sprintf("http://%s/frontend/public/", ln.Addr()))

The browser can reach the index.html file but cannot reach the bundled assets in the <project>/frontend/public/build directory and the webview console gives the following error:

Refused to apply style from 'http://127.0.0.1:44369/global.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Refused to apply style from 'http://127.0.0.1:44369/build/bundle.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Failed to load resource: the server responded with a status of 404 (Not Found)

Failed to load resource: the server responded with a status of 404 (Not Found)

Refused to apply style from 'http://127.0.0.1:44369/global.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Refused to apply style from 'http://127.0.0.1:44369/build/bundle.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Sorry if Im missing something obvious, Im new to Lorca and Go.
Thanks

@phanirithvij
Copy link

phanirithvij commented Jul 24, 2021

My suggestion is to use some http framework/library like Gin-Gonic or Gorilla mux to serve the static files.

@eyotang
Copy link

eyotang commented Dec 1, 2021

please refer it:
https://github.com/eyotang/counter

    subFs, _ := xfs.Sub(fs, "build")
go http.Serve(ln, http.FileServer(http.FS(subFs)))
ui.Load(fmt.Sprintf("http://%s", ln.Addr()))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants