Google spreadsheet API doesn't work on api/POST on Vercel but works on local

Viewed 173

Next.js app works fine on local and also on data fetching (getStaticProps) on vercel. However, post data form submission via pages/api/add is not working

Getting this error:

FetchError: request to https://www.googleapis.com/oauth2/v4/token failed, reason: Client network socket disconnected before secure TLS connection was established

Confirm that credentials generated from Google API are added as env variables and are correct without any typo.

With some debugging found that

  • Max execution limit is not a problem when I pass hardcoded values to getStaticProps and it gets inserted (on vercel and local)
  • POST data to goolesheets via api/add is not working (I've tried npm-google-spreadsheet and also official googleapis npm packages)
0 Answers
Related