下一个JS部署在Vercel,带有外部URL文件的Bug Background Imimage属性中
我在下一个。 该图像在本地显示,但是当我在Vercel中部署项目时,即使链接还可以,也不会显示背景图像... 我不能将图像放在公共文件夹中,因为我必须从Strapi获得它,
有人知道为什么?
import { getStrapiURL } from "../../../lib/api"
export default function SliderLargeScreen({ index, project }) {
const backgroundImage = getStrapiURL(
project.attributes.image.data.attributes.url
)
return (
<div index={index}>
<div
style={{
backgroundImage: `url(${backgroundImage})`,
height: "350px",
}}
className="relative bg-cover bg-center w-full flex flex-col rounded-md "
>
I have in my Next.js project a card component with a backgroundImage from my Strapi API.
The image is shown in local but when I deploy my project in Vercel it doesn't show the background image even if the link is ok...
I cannot put the image in public folder because I have to get it from Strapi
Someone has an idea why ?
import { getStrapiURL } from "../../../lib/api"
export default function SliderLargeScreen({ index, project }) {
const backgroundImage = getStrapiURL(
project.attributes.image.data.attributes.url
)
return (
<div index={index}>
<div
style={{
backgroundImage: `url(${backgroundImage})`,
height: "350px",
}}
className="relative bg-cover bg-center w-full flex flex-col rounded-md "
>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我已经解决了我的问题,这是一个愚蠢的错误,但是如果有人有相同的错误,
我仍在测试我的应用程序,而我的后端在我的VPS服务器上,但是whithout ssl证书,所以Vercel不想去通过http://upload/..png获取图片,而不是https:// .....由于安全冲突。
我在子域中安装了SSL证书,现在没关系! :)
Ok, I have fixed my issue, it was a stupid mistake but it can help if somebody has the same error :
I was still testing my app and my backend was on my vps server but whithout ssl certificate, so Vercel didn't want to get pictures with http://upload/.....png instead of https://..... because of security conflict.
I installed a SSL certificate on my subdomains and now it's OK ! :)