-
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
Add user agent to simple-get #1883
Conversation
Some sites (including Discord now) return a 403 error if no user agent is specified. Adding a user agent to the simple-get fixes the problem.
From the Discord Developers server:
|
Would it still be a good idea to add a user agent? |
In another Node.js package I help maintain, we decided to not set a default user-agent because Node.js doesn't set a default either. We did expose the ability for users to set any HTTP option (including any header) though. I'm not sure how we would provide that functionality in node-canvas without significantly deviating from the HTML spec, so I'm open to adding a U-A header (but something more accurate like |
Providing a hook wouldn't be bad would it? Something like |
I personally would like to see simple-get removed. along with Image ( #1845 ) a better proper way to load a image is via: createImageBitmap nodejs have added support for blobs, so one way to load binary images could be to do: import { Blob } from 'node:buffer'
import { createImageBitmap } from 'canvas/createImageBitmap.js'
const bitmap = await createImageBitmap(new Blob([ uint8 ]))
// Later paint bitmap to canvas |
I'm sure you saw this already, but it's used when |
well, i know it's being used when besides, not everything can be loaded with a simple get request. Other things require cookies or some other headers or methods. |
Some sites (including Discord now) return a 403 error if no user agent is specified. Adding a user agent to the simple-get fixes the problem.