<?php
header('Content-Type: application/json');
header('Cache-Control: no-store, no-cache');
require_once dirname(__DIR__) . '/include/config.php';

$host = vv_detect_host();
if (!preg_match('/^host\d+$/', $host)) {
    echo json_encode(['ok' => false, 'error' => 'Cannot detect local host']);
    exit;
}

echo json_encode(vv_auto_create_api_key($host, $host . '.conf'));
