I'm using the SDK for requests from my Next.js website. Everything works fine in localhost, but as soon as it is deployed on Vercel, I can only get 400 Errors for my requests to the API.
See the following code:
// Get the Dropbox API client
export const getDropboxApiClient = async () => {
const refreshToken = process.env.NEXT_PUBLIC_DROPBOX_REFRESH_TOKEN;
const appKey = process.env.NEXT_PUBLIC_DROPBOX_APP_KEY;
const appSecret = process.env.NEXT_PUBLIC_DROPBOX_APP_SECRET;
const dbx = new Dropbox({
clientId: appKey,
clientSecret: appSecret,
refreshToken: refreshToken,
});
return dbx;
};
// Get the available space for the account
const getAvailableSpace = async () => {
const dbx = await getDropboxApiClient();
const available = await dbx.usersGetSpaceUsage();
console.log(available);
};
This request works perfectly on localhost, and returns:

After I've deployed the App on Vercel, and added the environment variables the same way as usual (it works great with other SDKs), it doest work anymore.
All requests to the Dropbox API result in this:

Looking more closely into the network tab, I noticed that the request headers are different on localhost and deployed website. See the following, from localhost:

and on the website:

The request is exactly the same, except that it is missing the `authorization` field! Which explains the error message in the response:
Error in call to API function "users/get_space_usage": Must provide HTTP header "Authorization" or URL parameter "authorization".
I have no idea what I'm doing wrong here, or what I should do. Moreover, it seems that the initial request to Dropbox works fine, given the Vercel logs:

I hope someone will be familiar with this issue, and can provide me with some guidance. Here are some links to relevant parts of the code:
https://github.com/polar0/nilslepretre-photo-galley/blob/main/data/getDropboxApiClient.js
https://github.com/polar0/nilslepretre-photo-galley/blob/main/pages/admin/dashboard.js
Thanks!