mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-04-02 08:58:36 +02:00
add timeout to cors validation
This commit is contained in:
parent
644c53ec76
commit
af37c07656
@ -13,7 +13,7 @@ export default function SettingsView() {
|
||||
const { updateSettings, ...settings } = useAppSettings();
|
||||
|
||||
const form = useForm({
|
||||
mode: "onBlur",
|
||||
mode: "all",
|
||||
values: settings,
|
||||
});
|
||||
|
||||
@ -42,7 +42,7 @@ export default function SettingsView() {
|
||||
</Link>
|
||||
<Button
|
||||
ml="auto"
|
||||
isLoading={form.formState.isLoading}
|
||||
isLoading={form.formState.isLoading || form.formState.isValidating}
|
||||
isDisabled={!form.formState.isDirty}
|
||||
colorScheme="brand"
|
||||
type="submit"
|
||||
|
@ -29,7 +29,9 @@ async function validateInvidiousUrl(url?: string) {
|
||||
async function validateCorsProxy(url?: string) {
|
||||
if (!url) return true;
|
||||
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";
|
||||
} catch (e) {
|
||||
return "Cant reach instance";
|
||||
|
Loading…
x
Reference in New Issue
Block a user