Skip to content

Commit f60c1e2

Browse files
ralyodioclaude
andcommitted
fix(api): replace request.NextResponse.json() → request.json() sitewide
request.NextResponse is undefined on the NextRequest object. Every POST handler that used this typo threw a TypeError which was caught and returned as 400 "Invalid request format" (or 500 in uncaught paths). Fixed across 27 route files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 88ad92d commit f60c1e2

28 files changed

Lines changed: 31 additions & 31 deletions

File tree

‎src/app/api/auth/backup-pin/route.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export async function POST({ request }) {
136136
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
137137
}
138138

139-
const { pin } = await request.NextResponse.json();
139+
const { pin } = await request.json();
140140

141141
if (!pin || typeof pin !== 'string' || pin.length < 6 || pin.length > 12) {
142142
return NextResponse.json({ error: 'PIN must be 6-12 digits' }, { status: 400 });

‎src/app/api/auth/debug-sms-config/route.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export async function POST(request, { params } = {}) {
7979

8080

8181
try {
82-
const { testPhoneNumber } = await request.NextResponse.json();
82+
const { testPhoneNumber } = await request.json();
8383

8484
if (!testPhoneNumber) {
8585
return NextResponse.json(

‎src/app/api/auth/debug-sms/route.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function POST(request, { params } = {}) {
3939

4040

4141
try {
42-
const { phoneNumber, action = 'diagnose' } = await request.NextResponse.json();
42+
const { phoneNumber, action = 'diagnose' } = await request.json();
4343

4444
if (!phoneNumber) {
4545
return NextResponse.json(
@@ -64,7 +64,7 @@ export async function POST(request, { params } = {}) {
6464
});
6565

6666
case 'test-verify':
67-
const { verificationCode } = await request.NextResponse.json();
67+
const { verificationCode } = await request.json();
6868
if (!verificationCode) {
6969
return NextResponse.json(
7070
{ error: 'Verification code is required for verify test' },

‎src/app/api/auth/key-backup/route.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export async function PUT({ request }) {
138138
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
139139
}
140140

141-
const { encrypted_keys } = await request.NextResponse.json();
141+
const { encrypted_keys } = await request.json();
142142

143143
if (!encrypted_keys || typeof encrypted_keys !== 'string') {
144144
return NextResponse.json({ error: 'Missing or invalid encrypted_keys' }, { status: 400 });

‎src/app/api/auth/salt/route.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function GET({ url }) {
3333

3434
export async function POST({ request }) {
3535
try {
36-
const { phone, salt } = await request.NextResponse.json();
36+
const { phone, salt } = await request.json();
3737

3838
if (!phone || !salt) {
3939
return NextResponse.json({ error: 'Missing phone or salt' }, { status: 400 });

‎src/app/api/auth/verify-sms/route.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function POST(request, { params } = {}) {
4040

4141
// Parse JSON request body
4242
try {
43-
requestBody = await request.NextResponse.json();
43+
requestBody = await request.json();
4444
({ phoneNumber, verificationCode, username, displayName, useSession } = requestBody);
4545
} catch (parseError) {
4646
logger.error( 'Request body parsing failed', { error: parseError });

‎src/app/api/chat/conversations/route.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export async function GET(request, { params } = {}) {
8484
export async function POST(request, { params } = {}) {
8585
try {
8686
const supabase = await createSupabaseServerClient();
87-
const { type, name, participant_ids, group_id } = await request.NextResponse.json();
87+
const { type, name, participant_ids, group_id } = await request.json();
8888

8989
// Get user from session
9090
const { data: { user }, error: userError } = await supabase.auth.getUser();
@@ -227,7 +227,7 @@ export async function POST(request, { params } = {}) {
227227
export async function PATCH(request, { params } = {}) {
228228
try {
229229
const supabase = await createSupabaseServerClient();
230-
const { conversation_id, action } = await request.NextResponse.json();
230+
const { conversation_id, action } = await request.json();
231231

232232
// Get user from session
233233
const { data: { user }, error: userError } = await supabase.auth.getUser();

‎src/app/api/chat/messages/route.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export async function POST({ request }) {
101101
const userId = userData.id;
102102
console.log('🔐 [API] ✅ Internal user ID:', userId);
103103

104-
const { conversation_id, encrypted_contents, content_type = 'text', has_attachments = false, reply_to_id } = await request.NextResponse.json();
104+
const { conversation_id, encrypted_contents, content_type = 'text', has_attachments = false, reply_to_id } = await request.json();
105105

106106
// Validate required fields
107107
if (!conversation_id || !encrypted_contents) {

‎src/app/api/conversations/[id]/disappearing-messages/route.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export async function PUT({ params, request }) {
174174
return NextResponse.json({ error: 'Missing conversation ID' }, { status: 400 });
175175
}
176176

177-
const { disappear_seconds, start_on } = await request.NextResponse.json();
177+
const { disappear_seconds, start_on } = await request.json();
178178

179179
// Validate input
180180
if (typeof disappear_seconds !== 'number' || disappear_seconds < 0) {

‎src/app/api/conversations/archive/route.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { withAuth } from '@/lib/api/middleware/auth.js';
88

99
export const POST = withAuth(async ({ request, locals }) => {
1010
try {
11-
const { conversationId } = await request.NextResponse.json();
11+
const { conversationId } = await request.json();
1212

1313
if (!conversationId) {
1414
return NextResponse.json({ error: 'Missing conversationId' }, { status: 400 });

0 commit comments

Comments
 (0)