Files
cim_summary/backend/package.json
Jon 6057d1d7fd 🔧 Fix authentication and document upload issues
## What was done:
 Fixed Firebase Admin initialization to use default credentials for Firebase Functions
 Updated frontend to use correct Firebase Functions URL (was using Cloud Run URL)
 Added comprehensive debugging to authentication middleware
 Added debugging to file upload middleware and CORS handling
 Added debug buttons to frontend for troubleshooting authentication
 Enhanced error handling and logging throughout the stack

## Current issues:
 Document upload still returns 400 Bad Request despite authentication working
 GET requests work fine (200 OK) but POST upload requests fail
 Frontend authentication is working correctly (valid JWT tokens)
 Backend authentication middleware is working (rejects invalid tokens)
 CORS is configured correctly and allowing requests

## Root cause analysis:
- Authentication is NOT the issue (tokens are valid, GET requests work)
- The problem appears to be in the file upload handling or multer configuration
- Request reaches the server but fails during upload processing
- Need to identify exactly where in the upload pipeline the failure occurs

## TODO next steps:
1. 🔍 Check Firebase Functions logs after next upload attempt to see debugging output
2. 🔍 Verify if request reaches upload middleware (look for '�� Upload middleware called' logs)
3. 🔍 Check if file validation is triggered (look for '🔍 File filter called' logs)
4. 🔍 Identify specific error in upload pipeline (multer, file processing, etc.)
5. 🔍 Test with smaller file or different file type to isolate issue
6. 🔍 Check if issue is with Firebase Functions file size limits or timeout
7. 🔍 Verify multer configuration and file handling in Firebase Functions environment

## Technical details:
- Frontend: https://cim-summarizer.web.app
- Backend: https://us-central1-cim-summarizer.cloudfunctions.net/api
- Authentication: Firebase Auth with JWT tokens (working correctly)
- File upload: Multer with memory storage for immediate GCS upload
- Debug buttons available in production frontend for troubleshooting
2025-07-31 16:18:53 -04:00

81 lines
3.2 KiB
JSON

{
"name": "cim-processor-backend",
"version": "1.0.0",
"description": "Backend API for CIM Document Processor",
"main": "index.js",
"scripts": {
"dev": "ts-node-dev --respawn --transpile-only --max-old-space-size=8192 --expose-gc src/index.ts",
"build": "tsc && node src/scripts/prepare-dist.js && cp .puppeteerrc.cjs dist/",
"start": "node --max-old-space-size=8192 --expose-gc dist/index.js",
"test": "jest --passWithNoTests",
"test:watch": "jest --watch --passWithNoTests",
"test:gcs": "ts-node src/scripts/test-gcs-integration.ts",
"test:staging": "ts-node src/scripts/test-staging-environment.ts",
"test:integration": "jest --testPathPattern=integration",
"test:unit": "jest --testPathPattern=__tests__",
"test:coverage": "jest --coverage --passWithNoTests",
"setup:gcs": "ts-node src/scripts/setup-gcs-permissions.ts",
"lint": "eslint src --ext .ts",
"lint:fix": "eslint src --ext .ts --fix",
"db:migrate": "ts-node src/scripts/setup-database.ts",
"db:seed": "ts-node src/models/seed.ts",
"db:setup": "npm run db:migrate",
"deploy:firebase": "npm run build && firebase deploy --only functions",
"deploy:cloud-run": "npm run build && gcloud run deploy cim-processor-backend --source . --region us-central1 --platform managed --allow-unauthenticated",
"deploy:docker": "npm run build && docker build -t cim-processor-backend . && docker run -p 8080:8080 cim-processor-backend",
"docker:build": "docker build -t cim-processor-backend .",
"docker:push": "docker tag cim-processor-backend gcr.io/cim-summarizer/cim-processor-backend:latest && docker push gcr.io/cim-summarizer/cim-processor-backend:latest",
"emulator": "firebase emulators:start --only functions",
"emulator:ui": "firebase emulators:start --only functions --ui"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.57.0",
"@google-cloud/documentai": "^9.3.0",
"@google-cloud/storage": "^7.16.0",
"@supabase/supabase-js": "^2.53.0",
"axios": "^1.11.0",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"express-rate-limit": "^7.1.5",
"firebase-admin": "^13.4.0",
"firebase-functions": "^6.4.0",
"helmet": "^7.1.0",
"joi": "^17.11.0",
"jsonwebtoken": "^9.0.2",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"openai": "^5.10.2",
"pdf-parse": "^1.1.1",
"pg": "^8.11.3",
"puppeteer": "^21.11.0",
"redis": "^4.6.10",
"uuid": "^11.1.0",
"winston": "^3.11.0",
"zod": "^3.25.76"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.8",
"@types/jsonwebtoken": "^9.0.5",
"@types/morgan": "^1.9.9",
"@types/multer": "^1.4.11",
"@types/node": "^20.9.0",
"@types/pdf-parse": "^1.1.4",
"@types/pg": "^8.10.7",
"@types/supertest": "^2.0.16",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"eslint": "^8.53.0",
"jest": "^29.7.0",
"supertest": "^6.3.3",
"ts-jest": "^29.1.1",
"ts-node-dev": "^2.0.0",
"typescript": "^5.2.2"
}
}