I am currently in the process of transitioning my personal website from a Next.js JavaScript project to TypeScript. In the previous version, I used a placeholder background image loaded with the next/image system:
<Image
src="/filename.jpg"
layout="fill"
objectFit="cover"
quality={100}
/>
Initially, this setup worked fine albeit on the slower side. However, after switching to TypeScript without making any changes to the image loading line or related code, I started encountering a 502 (Bad Gateway) error when trying to load the image.
Interestingly, if I deliberately modify the URL to a non-existent file like "/falename.jpg", I receive a 400 (Bad Request) error instead. This indicates that the file access is functioning properly, but there seems to be an issue specifically when loading images in TypeScript.
Could there be a configuration step that I overlooked? Despite going through all of Next.js's documentation on next/image and TypeScript integration, I have not come across any references to this particular issue.