Skip to content

Commit d0684e5

Browse files
committed
chore: auth endpoint using auth token instead
1 parent d9d3f73 commit d0684e5

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

  • apps/app/src/app/api/stripe/repair

apps/app/src/app/api/stripe/repair/route.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { stripe } from '@/actions/organization/lib/stripe';
22
import { db } from '@comp/db';
33
import { SubscriptionType } from '@comp/db/types';
4+
import { NextResponse } from 'next/server';
45
import { syncStripeDataToKV } from '../syncStripeDataToKv';
56

67
// Type for request body
@@ -35,14 +36,21 @@ function successResponse(message: string, data?: any) {
3536
*/
3637
export async function POST(req: Request) {
3738
// Validate authentication
38-
const stripeRepairSecret = process.env.STRIPE_REPAIR_SECRET;
39-
if (!stripeRepairSecret) {
40-
return errorResponse('Server configuration error: Stripe repair secret not configured', 500);
39+
const retoolCompApiSecret = process.env.RETOOL_COMP_API_SECRET;
40+
if (!retoolCompApiSecret) {
41+
return errorResponse('Server configuration error: retool comp api secret not configured', 500);
4142
}
4243

43-
const authHeader = req.headers.get('x-stripe-repair-secret');
44-
if (authHeader !== stripeRepairSecret) {
45-
return errorResponse('Unauthorized', 401);
44+
const authHeader = req.headers.get('authorization');
45+
const token = authHeader?.split(' ')[1];
46+
if (!token || token !== retoolCompApiSecret) {
47+
return NextResponse.json(
48+
{
49+
success: false,
50+
error: 'Unauthorized',
51+
},
52+
{ status: 401 },
53+
);
4654
}
4755

4856
// Parse and validate request body

0 commit comments

Comments
 (0)