简体   繁体   English

如何将图像从自定义域加载到 next.config.js 以获取“next/image”/

[英]How to load images from custom domains to next.config.js for "next/image"/

I have two hostings, one is running nextjs on the domen.com.我有两个主机,一个在 domen.com 上运行 nextjs。 On the second img.domain.com.在第二个 img.domain.com 上。 And i use <Image src='img.domain.com/test.png' width="200" height="50" /> I get the error:我使用<Image src='img.domain.com/test.png' width="200" height="50" />我得到错误:

FetchError: request to https://img.domain.com/test.png failed, reason: read ECONNRESET

Beacuse, if i open via a direct link, then the pictures open, but with the parameters &w=1200&q=75 they do not open.因为,如果我通过直接链接打开,那么图片会打开,但参数 &w=1200&q=75 它们不会打开。 Nging get the error 404 Not Found Nging 得到错误404 Not Found

next.config.js下一步.config.js

module.exports = {   
    images: {
        domains: ['img.domain.com']
    },
}

You need to use the full domain inside the src attribute.您需要在 src 属性中使用完整域。 Something like the following像下面这样的东西

<Image src='https://img.domain.com/test.png' width="200" height="50" />

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM