Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,23 +639,32 @@ export const XPostAPI = {
}),
});

const data = await response.json();

if (!response.ok) {
// Check if this is an API configuration error (backwards compatibility)
if (data.error && data.error.includes('Bearer Token not configured')) {
console.warn('X API not configured, allowing action without verification');
verified = true;
} else {
// This is a real verification failure - user hasn't completed the action
throw new Error(data.error || `Verification failed. Please complete the ${actionType} action on X.com first, then try again.`);
}
// Check if response is JSON before parsing
const contentType = response.headers.get('content-type');
if (!contentType || !contentType.includes('application/json')) {
console.warn('API endpoint returned non-JSON response. The verification API may not be deployed correctly.');
console.warn(`Response status: ${response.status}, Content-Type: ${contentType}`);
// For backwards compatibility, allow the action when API is not available
verified = true;
} else {
verified = data.verified;
const data = await response.json();

if (!verified) {
// User hasn't actually completed the action on X.com
throw new Error(`Please complete the ${actionType} action on X.com first, then try again. Make sure you're logged into X.com with the account @${member.x_handle}.`);
if (!response.ok) {
// Check if this is an API configuration error (backwards compatibility)
if (data.error && data.error.includes('Bearer Token not configured')) {
console.warn('X API not configured, allowing action without verification');
verified = true;
} else {
// This is a real verification failure - user hasn't completed the action
throw new Error(data.error || `Verification failed. Please complete the ${actionType} action on X.com first, then try again.`);
}
} else {
verified = data.verified;

if (!verified) {
// User hasn't actually completed the action on X.com
throw new Error(`Please complete the ${actionType} action on X.com first, then try again. Make sure you're logged into X.com with the account @${member.x_handle}.`);
}
}
}
} catch (error: any) {
Expand Down
4 changes: 4 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"rewrites": [
{
"source": "/api/(.*)",
"destination": "/api/$1"
},
{
"source": "/(.*)",
"destination": "/"
Expand Down