下一个JS部署在Vercel,带有外部URL文件的Bug Background Imimage属性中

发布于 2025-01-28 10:05:46 字数 598 浏览 2 评论 0原文

我在下一个。 该图像在本地显示,但是当我在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

习惯成性 2025-02-04 10:05:46

好的,我已经解决了我的问题,这是一个愚蠢的错误,但是如果有人有相同的错误,

我仍在测试我的应用程序,而我的后端在我的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 ! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文