-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw error if fetching from relative URL on the server #203
Comments
Node.js 18: |
We need to unify that error message, also I think some fetch polyfills won't throw in that case. |
Not quite exactly on the topic, but is there any other option to fix this error other than inlining the image? |
You can fetch the image with an absolute URL such as |
Thanks for the answer, I should have been more clear. I was thinking about other solutions to local usage on the server. Is there currently any, aside of inlining? If not, would it be in scope for satori to extend towards this sever usage? For example a |
Hey! I'd love to take this issue (for my first OSS contribution) if it hasn't been assigned yet 🥳 |
Hey there, spent some time tinkering around the codebase, and I was wondering if the enhancement is as simple as checking the image // In src/handler/image.ts
// Check if on server
if (typeof window === 'undefined') {
// Check if src is absolute url
if (!src.startsWith('http') && !src.startsWith('data:')) {
throw new Error(`Image source must be an absolute URL: ${src}`)
}
} |
@multipletwigs that fix makes sense to me! Feel free to open a PR :) |
Addresses #203 by placing a check on absolute url patterns by checking if the URL begins with 'http' or 'data:' format. Also added in a test to check for relative urls.
Fixed with #447. |
Addresses vercel#203 by placing a check on absolute url patterns by checking if the URL begins with 'http' or 'data:' format. Also added in a test to check for relative urls.
Feature Request
Description
If running on the server, you cannot use
<img src="/my-img.png"/>
because there is no domain provided. We should throw a specific error message in that case.The text was updated successfully, but these errors were encountered: