Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

fix(billing): vercel cron not processing billing periods (#1112)

Type of Change

  • Bug fix

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Aug 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim (staging) Ready Ready Comment Aug 22, 2025 11:56pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Aug 22, 2025 11:56pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR fixes a critical authentication issue preventing Vercel's native cron jobs from executing billing processes. The core problem was that the existing authentication middleware only accepted Bearer token authentication, but Vercel cron jobs use a standard x-vercel-cron: 1 header instead of Authorization headers.

The changes modify the verifyCronAuth function in apps/sim/lib/auth/internal.ts to accept both authentication methods: the existing Bearer token approach for manual/external cron calls and the new Vercel cron header for Vercel's native cron system. This dual authentication approach maintains backward compatibility while enabling proper integration with Vercel's infrastructure.

Additionally, the daily billing endpoint (apps/sim/app/api/billing/daily/route.ts) was enhanced so that both GET and POST methods execute the actual billing processing logic (processDailyBillingCheck()), providing consistency and ensuring billing operations run regardless of the HTTP method used. A minor logging correction was also made to fix a misleading error message that incorrectly referenced 'monthly' instead of 'daily' billing.

These changes integrate with the existing authentication system shown in the codebase context, where the auth module handles various authentication methods and session management. The fix ensures that scheduled billing processes can execute properly in Vercel's serverless environment while maintaining security for other access patterns.

Confidence score: 4/5

  • This PR addresses a specific authentication bug with a targeted solution that maintains backward compatibility
  • Score reflects well-structured changes that follow established patterns but involves authentication logic that needs careful validation
  • Pay close attention to the authentication bypass logic in apps/sim/lib/auth/internal.ts to ensure it doesn't create security vulnerabilities

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@icecrasher321 icecrasher321 merged commit fdfa935 into main Aug 23, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant