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

**URL:** <https://discourse.gohugo.io/t/adding-audio-mpeg-to-mediatypes-allowlist-does-not-seem-to-work/50208>\
**Category:** support\
**Tags:** security\
**Created:** [June 8, 2024, 11:48am UTC](https://discourse.gohugo.io/t/adding-audio-mpeg-to-mediatypes-allowlist-does-not-seem-to-work/50208 "2024-06-08T11:48:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![CamilleScholtz](https://avatars.discourse-cdn.com/v4/letter/c/97f17d/32.png) [@CamilleScholtz](https://discourse.gohugo.io/u/CamilleScholtz)\
**Post date:** [June 8, 2024, 11:48am UTC](https://discourse.gohugo.io/t/adding-audio-mpeg-to-mediatypes-allowlist-does-not-seem-to-work/50208/1 "2024-06-08T11:48:20Z")

</div>

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

```auto
ERROR Unable to get remote resource http://127.0.0.1:8000/storage/articles/popper-een-afrekening/53d5e6ae-c841-4d06-a0b9-401bfe3cdc74.mp3: error calling resources.GetRemote: failed to resolve media type for remote resource "http://127.0.0.1:8000/storage/articles/popper-een-afrekening/53d5e6ae-c841-4d06-a0b9-401bfe3cdc74.mp3"

```

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

```toml
[security]
	[security.http]
		mediaTypes = ['^audio/mpeg$']

```

I get this error:

```auto
Error: error building site: process: readAndProcessContent: "/Users/camille/Developer/Home/reactionair.nl/content/articles/_content.gotmpl:68:8": template: /Users/camille/Developer/Home/reactionair.nl/content/articles/_content.gotmpl:68:8: executing "/Users/camille/Developer/Home/reactionair.nl/content/articles/_content.gotmpl" at <$.AddResource>: error calling AddResource: media type "audio/mpeg" not found

```

Anything I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 8, 2024, 12:32pm UTC](https://discourse.gohugo.io/t/adding-audio-mpeg-to-mediatypes-allowlist-does-not-seem-to-work/50208/2 "2024-06-08T12:32:31Z")

</div>

> [@CamilleScholtz](#):
>
> `http://127.0.0.1:8000`

Are you sure that the server at `http://127.0.0.1:8000` 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.

```plaintext
git clone --single-branch -b hugo-forum-topic-50208 https://github.com/jmooring/hugo-testing hugo-forum-topic-50208
cd hugo-forum-topic-50208
hugo server

```

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 8, 2024, 12:59pm UTC](https://discourse.gohugo.io/t/adding-audio-mpeg-to-mediatypes-allowlist-does-not-seem-to-work/50208/3 "2024-06-08T12:59:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 8, 2024, 4:42pm UTC](https://discourse.gohugo.io/t/adding-audio-mpeg-to-mediatypes-allowlist-does-not-seem-to-work/50208/4 "2024-06-08T16:42:05Z")

</div>

> [@CamilleScholtz](#):
>
> ```auto
> Error: error building site: process: readAndProcessContent: "/Users/camille/Developer/Home/reactionair.nl/content/articles/_content.gotmpl:68:8": template: /Users/camille/Developer/Home/reactionair.nl/content/articles/_content.gotmpl:68:8: executing "/Users/camille/Developer/Home/reactionair.nl/content/articles/_content.gotmpl" at <$.AddResource>: error calling AddResource: media type "audio/mpeg" not found
> 
> ```

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

The defaults are listed here:

> **[Custom output formats](https://gohugo.io/templates/output-formats/#media-types)**
>
> Hugo can output content in multiple formats, including calendar events, e-book formats, Google AMP, and JSON search indexes, or any custom text format.

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

---

<div class="post-metadata">

**Author:** ![CamilleScholtz](https://avatars.discourse-cdn.com/v4/letter/c/97f17d/32.png) [@CamilleScholtz](https://discourse.gohugo.io/u/CamilleScholtz)\
**Post date:** [June 8, 2024, 5:03pm UTC](https://discourse.gohugo.io/t/adding-audio-mpeg-to-mediatypes-allowlist-does-not-seem-to-work/50208/5 "2024-06-08T17:03:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 8, 2024, 5:13pm UTC](https://discourse.gohugo.io/t/adding-audio-mpeg-to-mediatypes-allowlist-does-not-seem-to-work/50208/6 "2024-06-08T17:13:57Z")

</div>

> [@bep](#):
>
> but you can easily add it to your site config

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](https://pkg.go.dev/mime#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.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 8, 2024, 5:25pm UTC](https://discourse.gohugo.io/t/adding-audio-mpeg-to-mediatypes-allowlist-does-not-seem-to-work/50208/7 "2024-06-08T17:25:17Z")

</div>

> [@jmooring](#):
>
> Do you happen to remember the conditions under which the allow list additions are required?

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [June 10, 2024, 5:26pm UTC](https://discourse.gohugo.io/t/adding-audio-mpeg-to-mediatypes-allowlist-does-not-seem-to-work/50208/8 "2024-06-10T17:26:15Z")

</div>

Closed on June 10, 2024, 5:26pm UTC

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