【问题标题】:Next.js 13 next.config.js "port" attribute for remotePatterns doesn't work for Image componentNext.js 13 next.config.js remotePatterns 的“端口”属性不适用于图像组件
【发布时间】: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


    【解决方案1】:

    我认为 443 端口已经用于 SSL。

    【讨论】:

      猜你喜欢
      • 2022-12-03
      • 2021-03-27
      • 1970-01-01
      • 2021-07-27
      • 2021-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-20
      相关资源
      最近更新 更多