mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-26 19:47:25 +02:00
add timeout to cors validation
This commit is contained in:
@@ -13,7 +13,7 @@ export default function SettingsView() {
|
|||||||
const { updateSettings, ...settings } = useAppSettings();
|
const { updateSettings, ...settings } = useAppSettings();
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
mode: "onBlur",
|
mode: "all",
|
||||||
values: settings,
|
values: settings,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ export default function SettingsView() {
|
|||||||
</Link>
|
</Link>
|
||||||
<Button
|
<Button
|
||||||
ml="auto"
|
ml="auto"
|
||||||
isLoading={form.formState.isLoading}
|
isLoading={form.formState.isLoading || form.formState.isValidating}
|
||||||
isDisabled={!form.formState.isDirty}
|
isDisabled={!form.formState.isDirty}
|
||||||
colorScheme="brand"
|
colorScheme="brand"
|
||||||
type="submit"
|
type="submit"
|
||||||
|
@@ -29,7 +29,9 @@ async function validateInvidiousUrl(url?: string) {
|
|||||||
async function validateCorsProxy(url?: string) {
|
async function validateCorsProxy(url?: string) {
|
||||||
if (!url) return true;
|
if (!url) return true;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(new URL("/https://example.com", url));
|
const controller = new AbortController();
|
||||||
|
const timeoutId = setTimeout(() => controller.abort(), 2000);
|
||||||
|
const res = await fetch(new URL("/https://example.com", url), { signal: controller.signal });
|
||||||
return res.ok || "Cant reach instance";
|
return res.ok || "Cant reach instance";
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return "Cant reach instance";
|
return "Cant reach instance";
|
||||||
|
Reference in New Issue
Block a user