-
Notifications
You must be signed in to change notification settings - Fork 63
Description
I am attempting to server-render an audio component that uses MP3 files uploaded to the Media Library in Prismic, but the client is returning Blobs which render them unusable once the site makes its way back to the client.
I've searched through the documentation and have not been able to find anyway to disable the blobs, but it feels like there must be some way to get the direct link to the media on Prismic somehow.
Since the client just makes calls to the API to fetch the urls, I'm wondering if this is a bug internal to the Prismic API that makes audio files unusable
Versions
- @prismicio/client: v7.17.2
- node: v20.11.0
- next (Next.js): v15.3.2
Reproduction
- Open Slice Machine
- Create a new
AudioPlayer
Slice - Create a new
Link to Media
field namedaudio_file
- Sync with Prismic
- Open Prismic to create an instance of the Slice
- Create an
AudioPlayer
slice on any page - Upload and attach an MP3 file
- Observe response from Prismic Client (URL is a
blob
local to the server
{
variation: 'default',
version: 'initial',
items: [],
primary: {
audio_file: {
link_type: 'Media',
key: '9xxxxx-a23a-4xxx-bxx4-0xxxx900xxx9',
kind: 'file',
id: 'temp-3xxxxxx4-3xx8-4xxd-axx1-5e9xxxxxxx76',
url: 'blob:https://myrepo.prismic.io/64xxxxxx-cxx9-4xx4-bxx7-4xxxxxxxxxx0',
name: 'SomeRandomMp3.mp3',
size: '7000000'
}
},
id: 'audio_player$fxxxxxx-3xx8-4xx6-bxxb-2xxxxxxxxxx1',
slice_type: 'audio_player',
slice_label: null
}
Steps to reproduce
Use a server-side rendering framework (Next.js in this case) and attempt to load the slice with the Prismic Client and place the URL returned by the client into the following as the src:
<audio controls>
<source src="<INSERT SOURCE HERE>"/>
</audio>
Optionally put type="audio/mpeg"
in the <source>
tag.
What is expected?
Prismic should return a normal https://
url rather than a blob:https://
url for the audio file and the <audio>
tag should be able to play the audio file just fine.
What is actually happening?
The Prismic Client returns a blob:
URL which will not work on any device except the Javascript environment that generated the blob.
I have not confirmed that the blob works when the Prismic Client is run on the client side instead of the server-side, but that would not solve the issue since I am trying to keep the client exclusively on the server.
I could not find a way to get the URL as an https://
url without a blob in the documentation, but maybe I am missing something.