I am using wix headless cms for my astro web app while fetching collection from wix the items i am receiving is
{
dataCollectionId: ‘Import197’,
data: {
body: ‘{“nodes”:[{“type”:“PARAGRAPH”,“id”:“foo”,“nodes”:[{“type”:“TEXT”,“id”:“”,“nodes”:,“textData”:{“text”:“Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Integer tincidunt varius nisi, vel fermentum ligula facilisis sit amet. Curabitur quis eros eu erat dignissim blandit. Duis non sapien nec libero dapibus vulputate. Nulla facilisi. Proin sed feugiat ligula, eget hendrerit risus. Maecenas efficitur, sapien vel tincidunt auctor, est nisi dapibus neque, id ultrices erat neque id sapien. Quisque ut orci venenatis, laoreet erat at, cursus lacus. Donec auctor enim non volutpat pellentesque. Suspendisse potenti. Etiam fermentum nisi vel nunc congue tempus.”,“decorations”:}}],“paragraphData”:{“textStyle”:{“textAlignment”:“AUTO”},“indentation”:0}},{“type”:“PARAGRAPH”,“id”:“2wvai179”,“nodes”:,“paragraphData”:{}},{“type”:“BUTTON”,“id”:“akoga178”,“nodes”:,“buttonData”:{“text”:“Download”,“styles”:{},“link”:{“target”:“BLANK”,“rel”:{“nofollow”:true}},“containerData”:{“textWrap”:true,“height”:{},“spoiler”:{},“alignment”:“CENTER”,“width”:{“size”:“ORIGINAL”}},“type”:“LINK”}},{“type”:“PARAGRAPH”,“id”:“8el4k180”,“nodes”:,“paragraphData”:{}}],“metadata”:{“version”:1,“createdTimestamp”:“2022-12-19T17:56:18.279Z”,“updatedTimestamp”:“2022-12-19T17:56:18.279Z”,“id”:“fe2f01f1-e561-420f-8b74-7b5a485e5655”},“documentStyle”:{}}’,
image: 'wix:image://v1/63181d_8d9d581494b849a0a2a8fa2ebb102ec8~mv2.webp/course.webp#originWidth=400&originHeight=400’,
description: ‘cuet material downloadd all supplements textbooks and helpbook guides to use it subscribe now’,
_id: ‘06a59ef6-c6f1-479f-878e-90671e0c6688’,
_owner: ‘245cb967-b311-40f2-8cb8-cca03385f0cf’,
_createdDate: [Object],
_updatedDate: [Object],
slug: ‘jee-mains’,
title: ‘Jee Mains’
},
_id: ‘06a59ef6-c6f1-479f-878e-90671e0c6688’
},
the issue is the url of image i am receiving is internal link which cannot be used in img or Image tag
that is : wix:image://v1/63181d_8d9d581494b849a0a2a8fa2ebb102ec8~mv2.webp/course.webp#originWidth=400&originHeight=400’
i had also tried to convert it into public url using fuction as follows:
// Function to process Wix image URLs
function getWixPublicUrl(wixUrl: string | undefined): URL | null {
if (!wixUrl || !wixUrl.startsWith(“wix:image://”)) {
return null;
}
try {
// Extract the image path
const imagePath = wixUrl.split(“wix:image://v1/”)[1]?.split(“#”)[0];
if (!imagePath) return null;
// Clean the path by removing any ~mv2 suffix
const cleanedPath = decodeURIComponent(imagePath.replace(/~mv2\.[^/]+/, ""));
// Construct the final URL
return new URL(`https://static.wixstatic.com/media/${cleanedPath}`);
} catch (error) {
console.error(“Error processing Wix image URL:”, error);
return null;
}
}
but the url received from this function looks like this
Final Image URL: https://static.wixstatic.com/media/63181d_8d9d581494b849a0a2a8fa2ebb102ec8/course.webp
which shows forbidden on search
help me out with this issue