mirror of
https://github.com/mito-systems/ranger-app.git
synced 2026-02-25 17:14:07 +00:00
wc fixes 2
This commit is contained in:
parent
7a0b0adef4
commit
c44ba31b04
@ -146,10 +146,18 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||
const formData = await req.formData()
|
||||
const imageFile = formData.get('image')
|
||||
|
||||
// Check for wallet address in both form data and headers
|
||||
// Check for wallet address in form data, URL params, and headers
|
||||
let walletAddress = formData.get('walletAddress');
|
||||
|
||||
// Also check custom header (this is more reliable with Next.js)
|
||||
// Check URL query parameters (most reliable on Vercel)
|
||||
const url = new URL(req.url);
|
||||
const queryWalletAddress = url.searchParams.get('wallet');
|
||||
if (queryWalletAddress && !walletAddress) {
|
||||
console.log('Found wallet address in URL query parameter:', queryWalletAddress);
|
||||
walletAddress = queryWalletAddress;
|
||||
}
|
||||
|
||||
// Also check custom header (less reliable with Vercel)
|
||||
const walletHeaderAddress = req.headers.get('X-Wallet-Address');
|
||||
if (walletHeaderAddress && !walletAddress) {
|
||||
console.log('Found wallet address in custom header:', walletHeaderAddress);
|
||||
@ -162,8 +170,10 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||
imageType: imageFile ? typeof imageFile : 'undefined',
|
||||
hasWalletAddressInForm: !!formData.get('walletAddress'),
|
||||
hasWalletAddressInHeader: !!walletHeaderAddress,
|
||||
hasWalletAddressInQuery: !!queryWalletAddress,
|
||||
requestUrl: req.url,
|
||||
searchParams: Object.fromEntries(url.searchParams.entries()),
|
||||
finalWalletAddress: walletAddress || 'Not provided',
|
||||
headers: Object.fromEntries(req.headers.entries()),
|
||||
formDataKeys: Array.from(formData.keys())
|
||||
});
|
||||
|
||||
|
||||
@ -110,19 +110,18 @@ const WildlifeIdentifier: React.FC = () => {
|
||||
console.log('Wallet connection status:', isWalletConnected());
|
||||
console.log('User wallet address:', userAddress || 'Not connected');
|
||||
|
||||
// Prepare custom headers including wallet address
|
||||
const headers = new Headers();
|
||||
|
||||
// Add wallet address as a custom header if available
|
||||
// Construct the URL with wallet address as a query parameter if available
|
||||
let url = '/api/analyze';
|
||||
if (userAddress) {
|
||||
console.log('Adding wallet address to custom header:', userAddress);
|
||||
headers.append('X-Wallet-Address', userAddress);
|
||||
// Encode the wallet address for URL safety
|
||||
const encodedWalletAddress = encodeURIComponent(userAddress);
|
||||
url += `?wallet=${encodedWalletAddress}`;
|
||||
console.log('Adding wallet address as query parameter:', userAddress);
|
||||
}
|
||||
|
||||
// Send to the Next.js API route with custom headers
|
||||
const response = await fetch('/api/analyze', {
|
||||
// Send to the Next.js API route with wallet in the URL
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: headers,
|
||||
body: formData
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user