import { Head } from '@inertiajs/react' import { useState } from 'react' import SettingsLayout from '~/layouts/SettingsLayout' import StyledButton from '~/components/StyledButton' import StyledSectionHeader from '~/components/StyledSectionHeader' import Alert from '~/components/Alert' import Input from '~/components/inputs/Input' import { useNotifications } from '~/context/NotificationContext' import { useMutation } from '@tanstack/react-query' import api from '~/lib/api' export default function AdvancedPage(props: { advanced: { internetStatusTestUrl: string internetStatusTestUrlEnvOverride: boolean } }) { const { addNotification } = useNotifications() const { internetStatusTestUrlEnvOverride } = props.advanced const [internetStatusTestUrl, setInternetStatusTestUrl] = useState( props.advanced.internetStatusTestUrl ?? '' ) const [testUrlError, setTestUrlError] = useState(null) // Mirror the backend validation (admin/app/validators/settings.ts) for instant // feedback. The backend remains the source of truth and returns 422 on failure. function validateTestUrl(value: string): string | null { if (value.trim() === '') return null // empty clears the setting try { const url = new URL(value) if (url.protocol !== 'http:' && url.protocol !== 'https:') { return 'Test URL must use http or https.' } } catch { return 'Test URL must be a valid URL (e.g. "https://example.com").' } return null } const updateTestUrlMutation = useMutation({ mutationFn: async (value: string) => { return await api.updateSetting('system.internetStatusTestUrl', value) }, onSuccess: () => { addNotification({ message: 'Setting updated successfully.', type: 'success' }) }, onError: (error: any) => { const msg = error?.response?.data?.message || error?.message || 'There was an error updating the setting. Please try again.' setTestUrlError(msg) addNotification({ message: msg, type: 'error' }) }, }) function handleSaveTestUrl() { const trimmed = internetStatusTestUrl.trim() const validationError = validateTestUrl(trimmed) if (validationError) { setTestUrlError(validationError) return } setTestUrlError(null) updateTestUrlMutation.mutate(trimmed) } return (

Advanced

Advanced configuration for operators. These settings are optional — the defaults work for most deployments.

N.O.M.A.D. periodically checks whether it can reach the internet. By default it probes Cloudflare's utility endpoint with a few fallbacks. Set a custom endpoint below if your network blocks the defaults. Leave blank to use the built-in defaults.

{internetStatusTestUrlEnvOverride && ( )}
{ setInternetStatusTestUrl(e.target.value) setTestUrlError(null) }} /> {testUrlError &&

{testUrlError}

}
Save
) }