I’m encountering a problem with relative paths when deploying my website via Vercel. For example, my site’s files are located at example.com/folder/index.html. Within this file, I reference an image in the same directory using ./img.jpg. However, after deploying the site, the image fails to load. The browser’s network tab shows the image path as example.com/img.jpg, even though the correct path should be example.com/folder/img.jpg based on the relative path.
This issue only occurs on Vercel. When testing locally, the image loads correctly. Additionally, deploying the same repository to GitHub Pages (e.g., username.github.io) also works as expected—the relative paths resolve properly. It seems Vercel is handling the path resolution differently.
Has anyone encountered similar behavior? I build a test website on https://test1-pi-rosy.vercel.app, you can view the source code.
-------------------------------UPDATE-------------------------------
I'm sorry, I should show two link. The root like this:
.├── folder| ├── index.html| └── img2.jpf├── index.html└── img1.jpgIn this link https://test1-pi-rosy.vercel.app,two picture can load correctly. (./img1.jpg and ./folder/img2.jpg)
But in this link https://test1-pi-rosy.vercel.app/folder,the second picture cant load, because it use relative path (../img1.jpg ✅ and ./img2 ❌)
