Adding audio/mpeg to mediaTypes allowlist does not seem to work

Trying to download an mp3 file using GetRemote I get the following error:

ERROR Unable to get remote resource error calling resources.GetRemote: failed to resolve media type for remote resource ""

And after adding the following lines to my hugo.toml:

		mediaTypes = ['^audio/mpeg$']

I get this error:

Error: error building site: process: readAndProcessContent: "/Users/camille/Developer/Home/": template: /Users/camille/Developer/Home/ executing "/Users/camille/Developer/Home/" at <$.AddResource>: error calling AddResource: media type "audio/mpeg" not found

Anything I’m doing wrong?

Are you sure that the server at is returning audio/mpeg as the content type? You can examine the response header in your browser’s dev tools.

Your config works fine for me with v0.127.0.

git clone --single-branch -b hugo-forum-topic-50208 hugo-forum-topic-50208
cd hugo-forum-topic-50208
hugo server

Also note that the allow list was added in v0.112.0.

The error suggests that the media type is missing from the config/defaults.

The defaults are listed here:

audio/mpeg isn not in the dfaults, but you can easily add it to your site config.

This seems to have indeed fixed the error. Thanks @jmooring and @bep!

1 Like

I had forgotten about this. Do you happen to remember the conditions under which the allow list additions are required? I can’t remember. It might have been:

  • URLs without extensions
  • Media types not handled by Go’s TypeByExtension
  • Something else

Or maybe the need for allow list additions was eliminated by changes since v0.112.0.

Don’t spend any time on this; only if you remember the details.

The gist of THIS issue is that the mediaType set in AddResource must be a configured media type. resources.GetRemote has some extended logic that I’m not able to spell out from memory on a Saturday night :slight_smile:


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.