Skip to content

Hugo serves imports of local mjs files as content-type text/plain #13822

Closed
@Dmytro-Shulha

Description

@Dmytro-Shulha

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.147.9-29bdbde19c288d190e889294a862103c6efb70bf+extended windows/amd64 BuildDate=2025-06-23T08:22:20Z

Does this issue reproduce with the latest release?

Yes.

A lil bit of context

I was working on my CV (code) and decided to add Gantt chart to it using Mermaid.js library.
This lib is distributed as ESM, and apparenly contains multiple chunks, each of which is requested separately.
Script responsible for enabling mermaidjs linked in (lines 24-25), and is looking like that:

Image

Image

Network activity shows, that if mermaid.js is imported directly from CDN (link) - it works, gantt chart is rendered.
Notice how chunks are responded with content-type: application/javascript.

Image

Now, when I copy script from CDN into local file, and try to import that - it doesn't work, gantt chart is not rendered.
Image
Notice how chunks are responded with content-type: text/plain
Image
Also, in Console tab, there are errors indicating that module download was blocked due to forbidden MIME type("text/plain")
Image

As for the main local mermaid.esm.min.mjs file - it 's media type can be configured in hugo.toml and it's being served by Hugo with content-type: text/javascript.

Image

Image

But, as I understand, if module itself consists of multiple modules - they are served by Hugo as text/plain, which leads to error that may have something to do with X-Content-Type-Options: nosniff in response header.

Unless there's a reason for hugo to behave like that, or a config option/workaround that I failed to find - it seems like a bug on Hugo side.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions