-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
How to use Sharp
library in API with Vercel?
#60409
Comments
// next.config.js
const nextConfig = {
webpack: (cfg, options = {}) => {
cfg.externals.push('sharp')
const { webpack } = options
const regex = /^sharp$/
cfg.plugins.push(new webpack.IgnorePlugin({
resourceRegExp: regex,
}))
}
} p.s. sharp unable to run on Edge runtime, sharp only can run on serverless function |
Ran into this again today, with a working system (and using the workaround from above to no avail). |
We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate. Why was this issue marked with the
|
Link to the code that reproduces this issue
https://github.com/rwecho/portal
To Reproduce
I reference the Sharp library by
pnpm add sharp
and enable the API to resize the image with it.It's working well locally. But when I deployed it to the Vercel, the API returned with 500 status.
The detailed log:
I searched for the issue, and could not distinguish that the sharp library is build-in.
Current vs. Expected behavior
In the app, we can use the Image component to optimize the image, how to handle it in API? thanks
Verify canary release
Provide environment information
The vercel environment, how to get the vercel info?
Which area(s) are affected? (Select all that apply)
Middleware / Edge (API routes, runtime)
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
No response
The text was updated successfully, but these errors were encountered: