`
const {
data: blog,
error,
mutate: mutateBlog,
} = useSWR<BlogData>(
`${process.env.NEXT_PUBLIC_BASE_API}/post/${params.blogId}/singlepost`,
fetcher
);
const [contentHTML, setContentHTML] = useState<string>("");
useEffect(() => {
if (blog) {
setCommentsCount(blog.commentsCount);
if (user && blog.likes.includes(user.id)) {
setIsLiked(true);
} else {
setIsLiked(false);
}
// Fetch content HTML when blog data is available
const fetchContent = async () => {
try {
const response = await fetch(blog?.contentURL);
if (!response.ok) {
throw new Error("Failed to fetch content");
}
const htmlContent = await response.text();
setContentHTML(htmlContent);
} catch (error) {
}
};
fetchContent();
}
}, [blog, user]);
`
WITH CONSOLE LOG BLOG.CONTENTURL IT GET URL. IN OTHER LAPTOP BROWERS AND POSTMAN THEIR IS NO CROS ERROR ERROR IN MOBILE BROWERS
`
7023-72ba09410ed12be2.js:1 TypeError: Failed to fetch at page-75e0765e054aaee6.js:1:1116 at page-75e0765e054aaee6.js:1:1298 at aW (fd9d1056-19524fffecc35dc0.js:1:73244) at oe (fd9d1056-19524fffecc35dc0.js:1:84685) at ol (fd9d1056-19524fffecc35dc0.js:1:85323) at or (fd9d1056-19524fffecc35dc0.js:1:85207) at ol (fd9d1056-19524fffecc35dc0.js:1:85303) at or (fd9d1056-19524fffecc35dc0.js:1:85207) at ol (fd9d1056-19524fffecc35dc0.js:1:86268) at or (fd9d1056-19524fffecc35dc0.js:1:85207)`
for backend I am using lambda function , cloundfront to access these s3 objects I have gave all access-origin to server index.js but still getting this
I tried to give all access-origin but it still did not work. I get cros error with 200 ok