[英]next/image fails to work when converting project from JavaScript to TypeScript
I'm working on converting my personal website from a Next.js JavaScript to TypeScript project.我正在将我的个人网站从 Next.js JavaScript 项目转换为 TypeScript 项目。 Previously I had a placeholder background image loaded with the next/image system:
以前我有一个用下一个/图像系统加载的占位符背景图像:
<Image
src="/filename.jpg"
layout="fill"
objectFit="cover"
quality={100}
/>
I am not using a loader at the moment.我目前没有使用装载机。 This successfully loaded, if a bit slow.
这成功加载,如果有点慢。 I moved to TypeScript with no changes to that line or related lines, but am now getting a 502 (Bad Gateway) error when attempting to load the image.
我移至 TypeScript 并没有更改该行或相关行,但现在尝试加载图像时出现 502(错误网关)错误。
If I modify the URL to a nonexistent file like "/falename.jpg" then I instead get a 400 (Bad Request) error.如果我将 URL 修改为不存在的文件,例如“/falename.jpg”,那么我会收到 400(错误请求)错误。 That seems to indicate that the file access is fine, but it's somehow not loading correctly in TypeScript only.
这似乎表明文件访问很好,但仅在 TypeScript 中无法正确加载。
Is there some setup step that I am missing?我缺少一些设置步骤吗? I've combed through all of Next.js's next/image and TypeScript guides and haven't noticed anything of the sort.
我已经梳理了所有 Next.js 的 next/image 和 TypeScript 指南,并没有注意到任何类似的东西。
Turns out the transition to TypeScript put some sort of cap on image file size;原来,过渡到 TypeScript 对图像文件大小设置了某种上限; I tried using lower resolution images and that worked.
我尝试使用较低分辨率的图像并且效果很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.