Hello Vercel Support Team,
I am encountering a persistent “Failed to retrieve the client token” error when attempting to upload images to Vercel Blob from my Next.js application. The error occurs in my /api/upload/route.ts serverless function, which uses @vercel/blob/client’s handleUpload function.
Here’s a summary of the situation and the troubleshooting steps I’ve already taken:
- Error Message: The exact error displayed in the application and console is:
Server Error: Failed to upload image: Vercel Blob: Failed to retrieve the client token
at uploadFileToBlob (/lib/client-upload)
at async uploadMultipleImagesClient (/lib/client-upload)
at async Object.uploadFiles (/components/client-image-upload)
at async handleSubmit (/app/dashboard/products/page)
- Environment Variable Configuration: I have verified in my Vercel project settings (under “Settings” > “Environment Variables”) that the
BLOB_READ_WRITE_TOKENis correctly set for “All Environments” and has a valid value. (I can provide a screenshot if needed). - Blob Store Status: I have also confirmed that my “stores” Blob Store is active and configured in the “Storage” tab of my Vercel project. (Screenshot available).
- Build and Deployment Status: My project builds and deploys successfully. The deployment logs show that the
/api/uploadroute is correctly identified and built as a serverless function. There are no critical errors or warnings during the build process that indicate an issue with environment variable access. (Screenshots of build logs available). - Vercel Status Page: I have checked status.vercel.com, and all systems are reported as operational.
- Code Implementation: My implementation for client uploads and the API route (
app/api/upload/route.tsandlib/client-upload.ts) follows the official Vercel Blob documentation for client uploads.
Despite these checks, the error persists, suggesting that the BLOB_READ_WRITE_TOKEN is not being correctly accessed by the serverless function at runtime.
Could you please help me investigate why the BLOB_READ_WRITE_TOKEN is not being retrieved by my serverless function during runtime? Any insights or further diagnostic steps you can provide would be greatly appreciated.
Thank you,
[Eng Amin]
