File tree Expand file tree Collapse file tree
apps/app/src/app/api/stripe/repair Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { stripe } from '@/actions/organization/lib/stripe' ;
22import { db } from '@comp/db' ;
33import { SubscriptionType } from '@comp/db/types' ;
4+ import { NextResponse } from 'next/server' ;
45import { syncStripeDataToKV } from '../syncStripeDataToKv' ;
56
67// Type for request body
@@ -35,14 +36,21 @@ function successResponse(message: string, data?: any) {
3536 */
3637export 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
You can’t perform that action at this time.
0 commit comments