65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
const { createClient } = require('@supabase/supabase-js');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// Read .env.local
|
|
const envPath = path.join(__dirname, '.env.local');
|
|
const envContent = fs.readFileSync(envPath, 'utf8');
|
|
const env = {};
|
|
envContent.split('\n').forEach(line => {
|
|
const parts = line.split('=');
|
|
if (parts.length >= 2) {
|
|
env[parts[0].trim()] = parts.slice(1).join('=').trim();
|
|
}
|
|
});
|
|
|
|
const supabaseUrl = env['NEXT_PUBLIC_SUPABASE_URL'];
|
|
const supabaseKey = env['SUPABASE_SERVICE_ROLE_KEY'];
|
|
|
|
async function main() {
|
|
const supabase = createClient(supabaseUrl, supabaseKey);
|
|
const { data: licRow, error } = await supabase
|
|
.from('settings')
|
|
.select('licserver_base_url, licserver_api_key')
|
|
.eq('id', 'licserver')
|
|
.single();
|
|
|
|
if (error || !licRow) {
|
|
console.error("Failed to load licserver config:", error);
|
|
return;
|
|
}
|
|
|
|
const base = 'http://192.168.178.174:9981'; // Target API port 9981
|
|
const apiKey = licRow.licserver_api_key;
|
|
|
|
console.log("Using API Base:", base);
|
|
console.log("API Key found:", apiKey ? "Yes (length " + apiKey.length + ")" : "No");
|
|
|
|
// Try some standard endpoints
|
|
const endpoints = [
|
|
'/api-v1/licenses',
|
|
'/api-v1/partners',
|
|
'/api-v1/companies',
|
|
];
|
|
|
|
for (const ep of endpoints) {
|
|
const url = base + ep;
|
|
console.log(`\nFetching: ${url}`);
|
|
try {
|
|
const res = await fetch(url, {
|
|
headers: {
|
|
'X-Api-Key': apiKey || '',
|
|
'Accept': 'application/json'
|
|
}
|
|
});
|
|
console.log(`Status: ${res.status} ${res.statusText}`);
|
|
const text = await res.text();
|
|
console.log(`Response (first 500 chars):`, text.substring(0, 500));
|
|
} catch (e) {
|
|
console.error(`Error fetching ${url}:`, e.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
main();
|