Skip to content

Commit 46b5d17

Browse files
authored
Merge pull request #67 from filiksyos/no-free-run-temporary
whatever
2 parents c6f6426 + 502d979 commit 46b5d17

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ VIEWS_IP_SALT=
3737
# Backend base URL for Custom reverse (local or your own deployment).
3838
# CUSTOM_REVERSE_SERVICE_URL=http://localhost:3001
3939

40+
# Free tier: Deep Reverse + Manual Control combined runs per calendar month (UTC).
41+
# Set to 0 to block free users entirely (paid subscribers bypass via checkout email header).
42+
# FREE_TIER_CUSTOM_LIMIT=1
43+
# NEXT_PUBLIC_FREE_TIER_CUSTOM_LIMIT=1
44+
4045
# --- Stripe checkout (optional: “Get Unlimited” on rate limit) ---
4146
# Server-side Checkout Session — success URL is set in code (?session_id={CHECKOUT_SESSION_ID}).
4247
# STRIPE_SECRET_KEY=sk_live_... # or sk_test_... for test mode

components/reverse-prompt-home.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ const GITREVERSE_HISTORY_MAX = 20;
1818
const HISTORY_PROMPT_PREVIEW_LEN = 160;
1919

2020
const RL_KEY_MONTHLY = "gr_rl_monthly";
21-
const MONTHLY_CUSTOM_LIMIT = 1;
21+
const MONTHLY_CUSTOM_LIMIT = Math.max(
22+
0,
23+
parseInt(process.env.NEXT_PUBLIC_FREE_TIER_CUSTOM_LIMIT ?? "1", 10)
24+
);
2225
const SUBSCRIBER_EMAIL_KEY = "gr_subscriber_email";
2326
const PENDING_REDIRECT_KEY = "gr_pending_redirect";
2427
const CHECKOUT_NAVIGATION_STATE_KEY = "gr_checkout_navigation_state";
@@ -1153,9 +1156,18 @@ export function ReversePromptHome({
11531156
role="alert"
11541157
>
11551158
<div className="flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between">
1156-
<p className="text-sm font-semibold text-zinc-900">
1157-
You&apos;ve hit this month&apos;s limit.
1158-
</p>
1159+
<div className="min-w-0 flex-1">
1160+
<p className="text-sm font-semibold text-zinc-900">
1161+
{MONTHLY_CUSTOM_LIMIT === 0
1162+
? "Deep Reverse and Manual Control are for paid subscribers only."
1163+
: "You've hit this month's limit."}
1164+
</p>
1165+
{MONTHLY_CUSTOM_LIMIT === 0 ? (
1166+
<p className="mt-1 text-xs text-zinc-600">
1167+
We don&apos;t have capacity to offer free runs right now.
1168+
</p>
1169+
) : null}
1170+
</div>
11591171
<div className="flex flex-wrap items-center gap-2">
11601172
{PAYMENT_LINK ? (
11611173
<Link

lib/custom-reverse-rate-limit.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { getSupabase } from "@/lib/supabase";
44
import { checkActiveSubscriber } from "@/lib/subscriber";
55
import { SUBSCRIBER_EMAIL_HEADER } from "@/lib/subscriber-constants";
66

7-
const MONTHLY_LIMIT = 1;
7+
const MONTHLY_LIMIT = Math.max(
8+
0,
9+
parseInt(process.env.FREE_TIER_CUSTOM_LIMIT ?? "1", 10)
10+
);
811
const RATE_LIMIT_RPC_TIMEOUT_MS = 2500;
912

1013
/** Skip DB-backed limits while developing locally or when explicitly opted out. */

0 commit comments

Comments
 (0)