-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Setting request headers for remote image requests #2099
Comments
I’m also affected by this; will try to make a quick PR soon |
1 task
Almost think that a http library and the way you would do it instead would be to: import { OffscreenCanvas, createImageBitmap } from 'canvas'
// using NodeJS v18 fetch, undici or node-fetch. or fetch-blob/from.js to get a blob
const blob = await fetch(url).then(res => res.blob())
const bitmap = await createImageBitmap(blob)
// draw bitmap to a new offscreen canvas.
const canvas = new OffscreenCanvas(bitmap.width, bitmap.height)
// ... This way you can make any request you like, changing user agent, Method, credentials etc. also changing accept header to allow for any |
This was referenced Jun 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue or Feature
Some websites block image requests made from canvas, for example Wikipedia. From Googling around it may be due to missing or invalid headers, e.g. User-Agent. Is there a way to set them currently? If not, please consider setting sane default headers or allowing the user to specify them for individual requests.
Steps to Reproduce
Your Environment
npm list canvas
oryarn list canvas
): [email protected]The text was updated successfully, but these errors were encountered: