Authentication or Database Error

The application could not connect to Google Cloud. This could be due to missing authentication credentials or an incomplete database setup in BigQuery.

For Local Development

Step 1: Authenticate Your Local Environment

  1. Ensure you have the Google Cloud CLI (gcloud) installed.
  2. Run the following command in your terminal and log in:
    gcloud auth application-default login
  3. Make sure your Google Cloud Project ID is set in a `.env.local` file in your project root:
    GCP_PROJECT=your-project-id-here

Step 2: Create BigQuery Dataset and Tables

If authentication is correct, the error might be that the required BigQuery tables do not exist. Go to the BigQuery SQL Workspace and run the queries found in the `docs/schema.sql` and `docs/data.sql` files to create and populate your tables.

For Deployed Solutions (On Cloud)

If your local environment works but the deployed app fails, it's a permission issue. Your deployed app runs as a **service account**, which needs to be granted permission to access BigQuery.

To fix this, go to the IAM page in your Google Cloud Console and grant the following roles to your service account:

  • BigQuery User: Allows running query jobs.
  • BigQuery Data Editor: Allows reading and writing data to tables.
  • Cloud Run Invoker: Allows the Next.js app to call your Cloud Run microservices.

You can find your service account email on the IAM & Admin page. It usually looks like `firebase-app-hosting-backend@...` or `...-compute@developer.gserviceaccount.com`.