mirror of
https://github.com/mito-systems/ranger-app.git
synced 2026-03-24 20:04:10 +00:00
logs
This commit is contained in:
parent
4a192519ac
commit
f6699c8985
@ -52,11 +52,12 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
console.log(`Processing token award for wallet ${walletAddress} and animal ${animalName || 'Unknown'}`);
|
||||
|
||||
// Check for environment variables
|
||||
const apiUrl = process.env.NEXT_PUBLIC_TOKEN_BACKEND_URL;
|
||||
const apiKey = process.env.NEXT_PUBLIC_TOKEN_API_KEY;
|
||||
|
||||
console.log(`Using backend URL: ${apiUrl || 'Not set'}, API key exists: ${!!apiKey}`);
|
||||
// Check and log all environment variables
|
||||
console.log('Environment variables check (award-tokens api):', {
|
||||
TOKEN_BACKEND_URL: process.env.NEXT_PUBLIC_TOKEN_BACKEND_URL || 'Not set',
|
||||
TOKEN_API_KEY_EXISTS: !!process.env.NEXT_PUBLIC_TOKEN_API_KEY,
|
||||
NODE_ENV: process.env.NODE_ENV
|
||||
});
|
||||
|
||||
const result = await awardTokensForSighting(walletAddress, userEmail, animalName || 'Unknown wildlife');
|
||||
|
||||
|
||||
@ -102,7 +102,15 @@ const ImageAnalysisCard: React.FC<ImageAnalysisCardProps> = ({
|
||||
if (walletAddress) {
|
||||
console.log(`Found wallet address: ${walletAddress}, awarding tokens`);
|
||||
|
||||
// Log environment variables (client-side only shows NEXT_PUBLIC_ ones)
|
||||
console.log('Environment variables (client-side):', {
|
||||
TOKEN_BACKEND_URL: process.env.NEXT_PUBLIC_TOKEN_BACKEND_URL || 'Not visible',
|
||||
TOKEN_API_KEY_EXISTS: !!process.env.NEXT_PUBLIC_TOKEN_API_KEY,
|
||||
NODE_ENV: process.env.NODE_ENV
|
||||
});
|
||||
|
||||
// Call our new token award endpoint
|
||||
console.log('Calling award-tokens endpoint...');
|
||||
const tokenResponse = await fetch('/api/award-tokens', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
@ -70,9 +70,14 @@ export const awardTokensForSighting = async (
|
||||
const totalReward = baseReward + rareBonus;
|
||||
|
||||
// Call the backend service to award tokens through the distributor
|
||||
const apiUrl = process.env.NEXT_PUBLIC_TOKEN_BACKEND_URL || 'http://localhost:3001';
|
||||
const apiUrl = process.env.NEXT_PUBLIC_TOKEN_BACKEND_URL;
|
||||
const apiKey = process.env.NEXT_PUBLIC_TOKEN_API_KEY || '';
|
||||
|
||||
if (!apiUrl) {
|
||||
console.error('Missing NEXT_PUBLIC_TOKEN_BACKEND_URL. Token awards will fail.');
|
||||
throw new Error('Token service URL not configured');
|
||||
}
|
||||
|
||||
console.log(`Sending token award request to ${apiUrl}/api/award-tokens`);
|
||||
|
||||
// Request tokens from the backend service
|
||||
@ -90,7 +95,7 @@ export const awardTokensForSighting = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
const errorData = await response.json().catch(() => ({ error: 'Unknown error' }));
|
||||
console.error('Token service error response:', errorData);
|
||||
throw new Error(errorData.error || 'Error from token service');
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user