【发布时间】:2022-11-16 03:35:39
【问题描述】:
下面的代码 sn-p 不起作用。我正在尝试在我的 next.config.js 文件中使用 remotePatterns 以允许外部图像。如果我将端口更改为空字符串“”,它就可以工作。当我指定“443”时,它不起作用。我不知道为什么。我错过了什么?提前致谢。
---
page.tsx:
import Image from "next/image";
function Homepage() {
return (
<div>
<Image
src="https://not-real-url.com/wp-content/uploads/not-real-logo.png"
width={50}
height={50}
alt="An image"
/>
</div>
);
}
export default Homepage;
---
next.config.js:
module.exports = {
reactStrictMode: true,
experimental: {
appDir: true,
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "not-real-url.com",
port: "443",
pathname: "/wp-content/uploads/*",
},
],
},
};
【问题讨论】:
标签: javascript reactjs next.js next.js13