<?php
//
// Copyright (c) 2025 Nagios Enterprises, LLC. All rights reserved.
//
// Serves the React app with HTTP 404 so Apache ErrorDocument 403/404 can point here.
// Both 403 and 404 are sent as 404 to avoid path mapping; the React app shows the ErrorPage.
//
http_response_code(404);
header('Content-Type: text/html; charset=UTF-8');
header('X-Robots-Tag: noindex, nofollow');

$index = dirname(__FILE__) . '/ui/dist/index.html';
if (is_file($index)) {
    readfile($index);
} else {
    echo '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>404 Not Found</title></head>';
    echo '<body><h1>Not Found</h1><p><a href="/nagiosxi/">Back to Nagios XI</a></p></body></html>';
}
