Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
3.7 KiB
3.7 KiB
Local Development with ngrok
This document explains how to use ngrok for local testing of Gmail Pub/Sub webhooks.
Prerequisites
- ngrok installed and configured
- Google Cloud service account with Pub/Sub permissions
- Gmail OAuth app configured
Quick Setup (Recommended)
1. Install ngrok
# macOS
brew install ngrok
# Other platforms: https://ngrok.com/download
2. Configure ngrok Authentication
- Sign up for ngrok: https://dashboard.ngrok.com/signup
- Get your authtoken: https://dashboard.ngrok.com/get-started/your-authtoken
- Install your authtoken:
ngrok authtoken YOUR_TOKEN_HERE
3. Start ngrok and Development Server
Option A: Two-terminal setup (Recommended)
# Terminal 1: Start ngrok
ngrok http 3000
# Terminal 2: Copy the https URL and start dev server
NGROK_URL=https://abc123.ngrok.io npm run dev
Option B: Use the helper script
# This shows instructions and starts the dev server
npm run dev:ngrok
# The script will display instructions and start the dev server
# Follow the displayed instructions to set up ngrok manually in another terminal
Option C: Quick command reference
# Get a reminder of the command format
npm run dev:with-ngrok
4. Helper Scripts
# Start ngrok with random subdomain
npm run ngrok:tunnel
# Start ngrok with custom subdomain (paid plans only)
npm run ngrok:start
How It Works
- ngrok tunnel: Creates a secure tunnel from the internet to your local port 3000
- Environment variable: The
NGROK_URLis automatically set by the startup script - Webhook configuration: Gmail Pub/Sub subscriptions automatically use the ngrok URL for webhooks
- Real-time testing: Gmail notifications are sent directly to your local development server
Testing
1. Verify ngrok is working
Visit your ngrok URL in a browser - you should see your local Next.js app.
2. Test Gmail provider setup
- Go to Email Settings in your local app
- Create a new Gmail provider
- Complete OAuth authorization
- Check the logs for Pub/Sub setup confirmation
3. Test webhook delivery
- Send an email to the configured Gmail account
- Check your development server logs for webhook notifications
- Look for log messages like:
🔔 Google Pub/Sub webhook notification received 📧 Decoded Gmail notification ✅ Published INBOUND_EMAIL_RECEIVED event
Environment Variables
The ngrok integration uses these environment variables:
NGROK_URL: Set automatically by the startup scriptNGROK_SUBDOMAIN: Optional, for custom subdomain (paid ngrok plans)
Troubleshooting
ngrok tunnel not starting
- Check if port 3000 is available
- Verify ngrok is installed:
ngrok version - For subdomain issues, check your ngrok plan
Webhook not receiving notifications
- Verify the ngrok URL is accessible from the internet
- Check Google Cloud Console for Pub/Sub subscription configuration
- Ensure Gmail watch subscription is active (7-day expiration)
Gmail watch subscription expired
Gmail watch subscriptions expire after 7 days. The system automatically renews them during OAuth authorization, but you can manually refresh by re-authorizing the Gmail provider.
Security Notes
- ngrok tunnels are publicly accessible
- Don't use production credentials in development
- Consider using ngrok's authentication features for sensitive testing
Scripts Reference
npm run dev:ngrok: Start both ngrok and development servernpm run ngrok:start: Start ngrok with custom subdomainnpm run ngrok:tunnel: Start ngrok with random subdomainnode scripts/dev-with-ngrok.js: Direct script execution