Skip to content

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

Merged
icecrasher321 merged 1 commit intostagingfrom
fix/billing-reset-periods
Aug 22, 2025
Merged

fix(billing): vercel cron not processing billing periods#1112
icecrasher321 merged 1 commit intostagingfrom
fix/billing-reset-periods

Conversation

@icecrasher321
Copy link
Collaborator

Summary

  • Accept x-vercel-cron: 1 in verifyCronAuth while retaining Bearer support.
  • GET now executes processDailyBillingCheck() and returns the same summary structure as POST.

Type of Change

  • Bug fix

Testing

Manually.

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 Ready Ready Preview Comment Aug 22, 2025 11:52pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Aug 22, 2025 11:52pm

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 issue preventing Vercel cron jobs from processing daily billing periods. The core problem was that Vercel's native cron system uses the x-vercel-cron: 1 header for authentication instead of custom Authorization headers, causing the existing Bearer token-only authentication to fail with 401 errors.

The fix involves two key changes:

  1. Authentication Enhancement: The verifyCronAuth function in apps/sim/lib/auth/internal.ts now accepts both Vercel's native cron header (x-vercel-cron: 1) and the existing Bearer token authentication. This maintains backward compatibility while enabling Vercel cron jobs to authenticate successfully.

  2. Endpoint Consistency: The daily billing route (apps/sim/app/api/billing/daily/route.ts) has been updated so that both GET and POST methods now execute the processDailyBillingCheck() function and return the same response structure. Previously, the GET endpoint was just a health check that returned a simple "OK" message.

The changes also include a minor bug fix in the error logging message, correcting "monthly" to "daily" billing cron job for accurate debugging information. This integration aligns with the existing billing infrastructure shown in the codebase context, where vercel.json configures a cron job to hit /api/schedules/execute every minute, and the authentication system in auth.ts manages various authentication methods.

Confidence score: 4/5

  • This PR is safe to merge with low risk as it addresses a specific deployment issue
  • Score reflects well-targeted changes that maintain backward compatibility while fixing a clear authentication problem
  • Pay close attention to apps/sim/lib/auth/internal.ts to ensure the dual authentication logic works correctly in production

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@icecrasher321 icecrasher321 merged commit 917552f into staging Aug 22, 2025
5 checks passed
@icecrasher321 icecrasher321 mentioned this pull request Aug 22, 2025
6 tasks
@waleedlatif1 waleedlatif1 deleted the fix/billing-reset-periods branch August 24, 2025 08:03
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
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