Skip to content
New issue

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

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

Already on GitHub? # to your account

MIME type #7

Open
delaneyj opened this issue Jul 6, 2024 · 1 comment
Open

MIME type #7

delaneyj opened this issue Jul 6, 2024 · 1 comment

Comments

@delaneyj
Copy link

delaneyj commented Jul 6, 2024

If I use the static path directly

<link rel="stylesheet" type="text/css" href="/static/css/site.css"/>

it works however if I generated the hashFS with a helper

<link rel="stylesheet" type="text/css" href={ staticPath("css/site.css") }/>
Refused to apply style from 'http://localhost:8080/servers/static/css/site-1630dff5128f31e61ad0a0b14c00d7e23df50237793a9c09d96bf564a8d54883.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Both way use the hashfs.FileServer so I'm surprised by the behavior. Any thoughts would helpful.

@adoublef
Copy link

is the staticPath function appending the static prefix after if locates the name using HashName? I had to do a bit of trickery when I just had an issue today:

func funcMap() template.FuncMap {
	return template.FuncMap{
		"static": func(s string) string {
			s = strings.TrimPrefix(s, "/static/")
			return "/static/" + static.HashName(s)
		},
	}
}

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

No branches or pull requests

2 participants