I'm hosting an expressjs app on Vercel, at some point it uses the spreadsheet api to store a generated product key. The function looks like this:
async function addActivationCode(activationCode)
{
await googleSheets.spreadsheets.values.append({
auth: googleAuth,
spreadsheetId: sheetID,
range: "ActivationCodes!A:C",
valueInputOption: "USER_ENTERED",
resource: {
values: [
[activationCode, "1", "0"]
]
}
})
}
This function works perfectly fine when hosted locally. But in Vercel's Realtime logs I get a FetchError saying: Client network socket disconnected before secure TLS connection was established.
the try-catch block that calls this function is the following:
try
{
await addActivationCode(generateActivationCode())
}
catch(err)
{
console.log(err)
console.log("Failed to add new activation code.")
return
}
Note that it is not the only function that sends an append request to the spreadsheet api. There's another function used to add users and it's working fine. Here it is:
async function addUser(username, password)
{
// Generate salt and hash the password in one command
const hashedPassword = await bcrypt.hash(password, 10)
// Add user to the Users sheet
await googleSheets.spreadsheets.values.append({
auth: googleAuth,
spreadsheetId: sheetID,
range: "Users!A2:B",
valueInputOption: "USER_ENTERED",
resource: {
values: [
[username, hashedPassword]
]
}
})
}
I found another post talking about this issue but not in Vercel. It was related to proxies. My knowledge about proxies atm is limited so I didn't quite understand how to fix this in Vercel.
Any help is appreciated.