I’m currently running into this issue when deploying my Next.JS app in Vercel:
<code>Error occurred prerendering page "/api/full". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at f.getApplicationDefaultAsync (/vercel/path0/fpl-app/.next/server/chunks/30.js:13:25829)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async f.getClient (/vercel/path0/fpl-app/.next/server/chunks/30.js:13:31934)
at async f.request (/vercel/path0/fpl-app/.next/server/chunks/30.js:13:32692)
at async C.getInstanceMetadata (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:47324)
at async R.performRefresh (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:45221)
at async R.getCloudSQLInstance (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:43464)
at async S.loadInstance (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:49857)
at async D.getOptions (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:50733)
at async l (/vercel/path0/fpl-app/.next/server/app/api/full/route.js:1:4501)
(node:338) MetadataLookupWarning: received unexpected error = Unsuccessful response status code. Request failed with status code 401 code = UNKNOWN
<code>Error occurred prerendering page "/api/full". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at f.getApplicationDefaultAsync (/vercel/path0/fpl-app/.next/server/chunks/30.js:13:25829)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async f.getClient (/vercel/path0/fpl-app/.next/server/chunks/30.js:13:31934)
at async f.request (/vercel/path0/fpl-app/.next/server/chunks/30.js:13:32692)
at async C.getInstanceMetadata (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:47324)
at async R.performRefresh (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:45221)
at async R.getCloudSQLInstance (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:43464)
at async S.loadInstance (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:49857)
at async D.getOptions (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:50733)
at async l (/vercel/path0/fpl-app/.next/server/app/api/full/route.js:1:4501)
(node:338) MetadataLookupWarning: received unexpected error = Unsuccessful response status code. Request failed with status code 401 code = UNKNOWN
</code>
Error occurred prerendering page "/api/full". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at f.getApplicationDefaultAsync (/vercel/path0/fpl-app/.next/server/chunks/30.js:13:25829)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async f.getClient (/vercel/path0/fpl-app/.next/server/chunks/30.js:13:31934)
at async f.request (/vercel/path0/fpl-app/.next/server/chunks/30.js:13:32692)
at async C.getInstanceMetadata (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:47324)
at async R.performRefresh (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:45221)
at async R.getCloudSQLInstance (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:43464)
at async S.loadInstance (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:49857)
at async D.getOptions (/vercel/path0/fpl-app/.next/server/chunks/30.js:58:50733)
at async l (/vercel/path0/fpl-app/.next/server/app/api/full/route.js:1:4501)
(node:338) MetadataLookupWarning: received unexpected error = Unsuccessful response status code. Request failed with status code 401 code = UNKNOWN
When running it locally I had no issues, presumably because I’m able to run the “gcloud auth application-default login” command. I’ve added the GCloud integration with Vercel, linked it and created the service account key file, and added it to Vercel. It created the env variables linked to Google, however, I cannot figure out how to properly use them to authorize. The docs (https://www.gcpvercel.com/docs/usage) show an example of how to access a Storage bucket, however, I’m using their Cloud DB service, so I’m not quite sure how to authorize properly.
I’m currently accessing my DB with the ‘mysql2/promise’ library, with this code:
<code>const pool = await mysql.createPool({
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME
<code>const pool = await mysql.createPool({
...clientOpts,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME
})
</code>
const pool = await mysql.createPool({
...clientOpts,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME
})
Any help would be appreciated!