Last Updated: 2025-12-24
Completed Phases:
- ✅ Phase 1: Database Schema & Queries (user_settings, daily_summaries tables)
- ✅ Phase 2: AI Service Layer (OpenRouter integration with xiaomi/mimo-v2-flash:free model)
Current Issue:
- 🔄 iOS Shortcuts debugging - shortcut sends GET instead of POST to /api/content
- ✅ Backend validated via curl from iSH terminal - works perfectly
- ❌ iOS Shortcuts making unexpected GET requests despite being configured for POST
Enhancing iOS Share Sheet Backend with AI-powered daily summaries and PWA frontend.
Token: OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY
https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run
Email: jb@saluamigo.com
Name: John B.
Files Created:
backend/database/migrations_v2.ts- New tables for user settings and daily summariesbackend/database/queries_v2.ts- Date-range and summary query functions
Files Modified:
shared/types.ts- Added UserSettings and DailySummary interfacesbackend/index.ts- Runs v2 migrations on startup
Database Tables:
user_settings (userId, emailEnabled, smsEnabled, smsPhone, summaryTime, timezone, summaryTone, summaryLength, includeContentTypes, createdAt, updatedAt) daily_summaries (id, userId, summary, contentItemsCount, contentTypes, generatedAt, deliveredAt, createdAt)
Files Created:
backend/services/aiService.ts- AI summary generation with OpenRouter/Groq/Straicobackend/services/emailService.ts- Email delivery via Val Town std/emailbackend/services/smsService.ts- SMS delivery via Zapier webhooks
Files Modified:
backend/routes/content.ts- Added test endpoints for AI functionalitybackend/routes/auth.ts- Added test endpoints for authentication bypass
Environment Variables (configured in Val Town):
AI_PROVIDER=openrouter
AI_API_KEY=sk-or-v1-...
AI_BASE_URL=https://openrouter.ai/api/v1
Test Endpoints Added:
POST /api/content/ai-summary-test- Generate summary from last 24h contentPOST /api/content/add-sample-data- Add 7 sample content itemsGET /api/content/ai-test- Test AI service configurationPOST /api/content/test-email- Send test emailPOST /api/auth/test-create-token- Create bearer token (bypasses auth)POST /api/auth/test-login- Test login (bypasses WebAuthn)GET /backend/test/createUser- Create user account (no WebAuthn)
Testing Phase 2:
# Test page https://www.val.town/x/jaballadares/test-phase2 # Or manual testing: curl -X POST "https://jaballadares.../api/content/ai-summary-test" \ -H "Authorization: Bearer OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY"
iOS Shortcuts "Get Contents of URL" action sends GET requests instead of POST to /api/content, despite being configured for POST method with headers and body.
# This curl command from iSH terminal works perfectly: curl -X POST \ "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/content" \ -H "Authorization: Bearer OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY" \ -H "Content-Type: application/json" \ -d '{"type":"text","content":"Test from iSH","title":"iSH Test"}' # Returns: {"success":true,"id":"...","message":"Content saved successfully"}
- iOS Shortcuts configured with:
- Method: POST
- URL:
https://jaballadares.../api/content - Headers: Authorization + Content-Type
- Request Body: JSON with type/content/title
- But Val Town logs show:
GET /api/content 401 Unauthorizedwith NO Authorization header
Just deployed to backend/routes/content.ts:
- Logs ALL incoming requests with method, URL, headers, body
- Logs bearer token validation steps
- Shows exactly what iOS Shortcuts is sending
Log output format:
=== INCOMING REQUEST ===
Timestamp: ...
Method: GET or POST
URL: /api/content
Headers: {...}
Body: {...}
========================
=== BEARER TOKEN CHECK ===
Auth header: Bearer...
✅ Auth successful for user: jb@saluamigo.com
Investigate why iOS Shortcuts sends GET instead of POST:
- Check Val Town logs after running shortcut
- Verify shortcut configuration (screenshot showed correct POST method)
- May need to try alternative iOS Shortcuts approach
- Consider if iOS version or Shortcuts version has bugs
- Create Val Town cron jobs to generate and deliver summaries daily
- File:
cron/generateDailySummaries.cron.tsx - File:
cron/deliverSummaries.cron.tsx - Add Zapier webhook integration for SMS delivery
frontend/components/Settings.tsx- User preferences for summariesfrontend/components/Summaries.tsx- View past summariesbackend/routes/settings.ts- Settings API endpointsbackend/routes/summaries.ts- Summaries API endpoints
- PWA manifest and service worker
- Client-side routing
- Mobile-first navigation
- Performance optimizations
- Dark mode toggle
- Export functionality (PDF, Markdown, text)
- Accessibility improvements
- Lighthouse score > 90
File: backend/routes/content.ts
Added comprehensive logging middleware:
// Logs ALL requests to /api/content
content.use("/*", async (c, next) => {
console.log("=== INCOMING REQUEST ===");
console.log("Timestamp:", new Date().toISOString());
console.log("Method:", c.req.method);
console.log("URL:", c.req.url);
console.log("Path:", c.req.path);
console.log("Headers:", Object.fromEntries(c.req.header()));
console.log("Body:", body || "(empty)");
await next();
});
// Enhanced bearer token logging
async function requireBearerToken(c: any, next: any) {
console.log("=== BEARER TOKEN CHECK ===");
console.log("Auth header:", authHeader ? authHeader.substring(0, 20) + "..." : "(none)");
// ... detailed logging through auth flow
}
File: frontend/components/Setup.tsx
Fixed misleading UI that claimed downloadable iOS shortcut existed:
- Changed Step 2 from "Download iOS Shortcut" to "Create the iOS Shortcut"
- Added detailed manual instructions for creating shortcut
- Removed fake download button
- Status: Fixed locally, not pushed to Val Town per user request
curl -X POST "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/content" \ -H "Authorization: Bearer OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY" \ -H "Content-Type: application/json" \ -d '{"type":"text","content":"Test note","title":"Test"}'
curl -X POST "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/content/ai-summary-test" \ -H "Authorization: Bearer OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY"
curl -X POST "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/content/add-sample-data" \ -H "Authorization: Bearer OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY"
curl -X POST "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/auth/test-create-token" \ -H "Content-Type: application/json" \ -d '{"email":"jb@saluamigo.com"}'
# Must be logged in via browser first curl -X POST "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/content/test-email" \ -H "Content-Type: application/json"
- Web Session (for dashboard): Cookie-based auth via
/api/auth/test-login - Bearer Token (for iOS Shortcuts): Authorization header with Bearer token
users- User accountsweb_authn_credentials- Passkeys (not used currently)bearer_tokens- API access tokens for shortcutscontent_items- Captured content (text, images, URLs)user_settings- Summary preferences (email, SMS, tone, length, timezone)daily_summaries- Generated daily summaries
- Provider: OpenRouter
- Model: xiaomi/mimo-v2-flash:free (free tier)
- Fallback: Can switch to Groq or Straico via env vars
- Tone Options: professional, casual, detailed, brief, balanced
- Length Options: short, medium, long
-
HIGH PRIORITY: Resolve iOS Shortcuts GET vs POST issue
- Check Val Town logs after running shortcut
- Verify what iOS Shortcuts is actually sending
- Try alternative approaches if needed
-
After iOS Shortcuts works:
- Test end-to-end flow (iOS capture → content stored)
- Deploy Phase 3 (Cron Jobs)
- Build Phase 4 (Settings & Summaries UI)
-
Nice to have:
- Push Setup.tsx fix (remove fake download button)
- Test email delivery
- Generate and view first real daily summary
- Dashboard: https://www.val.town/x/jaballadares/sharesheet_thing
- Console/Logs: https://www.val.town/x/jaballadares/sharesheet_thing (view logs in browser)
- Test Page: https://www.val.town/x/jaballadares/test-phase2
- Backend Source: Mounted at
/backendin this repo
-
Why does iOS Shortcuts send GET instead of POST?
- iOS version compatibility?
- Shortcuts app bug?
- Request body formatting issue?
- SSL/certificate issue causing fallback?
-
Why is Authorization header not being sent?
- iOS security stripping the header?
- URL encoding issue?
- Shortcuts app limitation?
-
Workarounds to try:
- Use URL parameters instead of headers for token?
- Use different iOS Shortcuts action?
- Build custom iOS app instead of Shortcuts?
- Use third-party automation tool?
Good luck with the debugging! The backend is solid - just need to figure out what iOS Shortcuts is doing differently than curl. 🚀