Bonjour Sébastien!
If you only care if a server is up, in the sense that responds-to-requests, could you use no-cors?
something like this should work if so
```
async function urlIsUp(url) {
try {
const serverResponse = await fetch(url, {
method: 'HEAD',
mode: 'no-cors'
})
return !!serverResponse
} catch (e) {
return false
}
}
````
You can use an abort controller if you want to have a timeout
```
async function urlIsUp(url) {
const secondsBeforeTimeout = 8;
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), secondsBeforeTimeout * 1000);
try {
const serverResponse = await fetch(url, {
method: 'HEAD',
mode: 'no-cors',
signal: controller.signal
});
clearTimeout(timeoutId);
return true;
} catch (e) {
return false;
}
}
```
patrick