Hey guys! I'm using Next.js and having some issues generating signed URLs to access a video stored o
Hey guys!
I'm using Next.js and having some issues generating signed URLs to access a video stored on cloudflare stream. this is my code:
const cloudflareTokenResponse = await fetch(
method: 'POST',
headers: {
'Authorization':
'Content-Type': 'application/json',
},
});
if (!cloudflareTokenResponse.ok) {
return res.status(500).json({ message: 'Failed to generate Cloudflare token' });
}
const cloudflareTokenData = await cloudflareTokenResponse.json();
const signedUrl =
console.log(signedUrl)
return res.status(200).json({ signedUrl });
The URL is generated successfully, I get no errors there, but every time I try to access the generated url, I get an error 401 unauthorized. any idea what may be causing it? I have "Require Signed URLs" checked on the video settings
I'm using Next.js and having some issues generating signed URLs to access a video stored on cloudflare stream. this is my code:
const cloudflareTokenResponse = await fetch(
https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/stream/${VIDEO_UID}/token, {method: 'POST',
headers: {
'Authorization':
Bearer ${CLOUDFLARE_API_TOKEN},'Content-Type': 'application/json',
},
});
if (!cloudflareTokenResponse.ok) {
return res.status(500).json({ message: 'Failed to generate Cloudflare token' });
}
const cloudflareTokenData = await cloudflareTokenResponse.json();
const signedUrl =
https://videodelivery.net/${VIDEO_UID}/manifest/video.m3u8?token=${cloudflareTokenData.result.token};console.log(signedUrl)
return res.status(200).json({ signedUrl });
The URL is generated successfully, I get no errors there, but every time I try to access the generated url, I get an error 401 unauthorized. any idea what may be causing it? I have "Require Signed URLs" checked on the video settings
