0

So I have a website written using Astro that collects stamps. It has an API written in React that will read from the Firebase DB. When I ran it locally, it works just fine. But when I hosted it to Vercel, an error pops up:

Error fetching stamps: Error: Unable to detect a Project Id in the current environment. 
To learn more about authentication and Google APIs, visit: 
https://cloud.google.com/docs/authentication/getting-started
    at GoogleAuth.findAndCacheProjectId (/var/task/node_modules/.pnpm/[email protected]/node_modules/google-auth-library/build/src/auth/googleauth.js:170:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Firestore.initializeIfNeeded (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@google-cloud/firestore/build/src/index.js:1197:35)
    at async Module.GET (file:///var/task/dist/server/pages/api/stamp.astro.mjs:98:21)
    at async renderEndpoint (file:///var/task/dist/server/chunks/astro/server_T2yNNXBH.mjs:441:18)
    at async lastNext (file:///var/task/dist/server/chunks/entrypoint_BdQR0ZKK.mjs:3116:23)
    at async callMiddleware (file:///var/task/dist/server/chunks/entrypoint_BdQR0ZKK.mjs:1147:10)
    at async RenderContext.render (file:///var/task/dist/server/chunks/entrypoint_BdQR0ZKK.mjs:3160:22)
    at async NodeApp.render (file:///var/task/dist/server/chunks/entrypoint_BdQR0ZKK.mjs:3834:18)
    at async Server.handler (file:///var/task/dist/server/chunks/entrypoint_BdQR0ZKK.mjs:13675:29)
Caused by: Error
    at /var/task/node_modules/.pnpm/@[email protected]/node_modules/@google-cloud/firestore/build/src/index.js:1040:27
    at /var/task/node_modules/.pnpm/@[email protected]/node_modules/@google-cloud/firestore/build/src/telemetry/enabled-trace-util.js:110:30
    at NoopContextManager.with (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js:25:19)
    at ContextAPI.with (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@opentelemetry/api/build/src/api/context.js:60:46)
    at NoopTracer.startActiveSpan (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js:65:31)
    at ProxyTracer.startActiveSpan (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js:36:24)
    at EnabledTraceUtil.startActiveSpan (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@google-cloud/firestore/build/src/telemetry/enabled-trace-util.js:102:28)
    at Firestore.getAll (/var/task/node_modules/.pnpm/@[email protected]/node_modules/@google-cloud/firestore/build/src/index.js:1031:32)
    at /var/task/node_modules/.pnpm/@[email protected]/node_modules/@google-cloud/firestore/build/src/reference/document-reference.js:182:36
    at /var/task/node_modules/.pnpm/@[email protected]/node_modules/@google-cloud/firestore/build/src/telemetry/enabled-trace-util.js:110:30

I've tried changing the environment variables on Vercel already and the same thing still happens. So I'm not sure what is wrong and how I should attempt to fix it.

Below here is the example of my .env file:

FIREBASE_PRIVATE_KEY_ID=YOUR_PRIVATE_KEY_ID
FIREBASE_PRIVATE_KEY=YOUR_PRIVATE_KEY
FIREBASE_PROJECT_ID=YOUR_PROJECT_ID
FIREBASE_CLIENT_EMAIL=YOUR_CLIENT_EMAIL
FIREBASE_CLIENT_ID=YOUR_CLIENT_ID
FIREBASE_AUTH_URI=YOUR_AUTH_URI
FIREBASE_TOKEN_URI=YOUR_TOKEN_URI
FIREBASE_AUTH_CERT_URL=YOUR_AUTH_CERT_URL
FIREBASE_CLIENT_CERT_URL=YOUR_CLIENT_CERT_URL
API_KEY=YOUR_API_KEY
AUTH_DOMAIN=YOUR_AUTH_DOMAIN
PROJECT_ID=YOUR_PROJECT_ID
STORAGE_BUCKET=YOUR_STORAGE_BUCKET
MESSAGING_SENDER_ID=YOUR_MESSAGING_SENDER_ID
APP_ID=YOUR_APP_ID
MEASUREMENT_ID=YOUR_MEASUREMENT_ID

If there is anything more to add please tell me. Thanks for the help.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.