mirror of
https://github.com/bastienwirtz/homer.git
synced 2024-11-07 08:44:00 +01:00
allow setting no-cors in ping service
Signed-off-by: Jayadeep KM <kmjayadeep@gmail.com>
This commit is contained in:
parent
df903a2c04
commit
37509200fc
@ -144,6 +144,8 @@ For Ping you need to set the type to Ping and provide a url. By default the HEAD
|
||||
method: "head"
|
||||
```
|
||||
|
||||
You can also specify an optional field `mode` as `no-cors` to allow cross-origin requests from the browser. Setting this field will show the status of the service as `online` if the request is successful, irrespective of the response status code. Check the official [documentation](https://developer.mozilla.org/en-US/docs/Web/API/Request/mode) for more information about this field.
|
||||
|
||||
## Prometheus
|
||||
|
||||
For Prometheus you need to set the type to Prometheus and provide a url.
|
||||
|
@ -39,7 +39,9 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
this.fetch("/", { method, cache: "no-cache" }, false)
|
||||
const mode = typeof this.item.mode === "string" ? this.item.mode : "cors";
|
||||
|
||||
this.fetch("/", { method, cache: "no-cache", mode }, false)
|
||||
.then(() => {
|
||||
this.status = "online";
|
||||
})
|
||||
|
@ -38,6 +38,11 @@ export default {
|
||||
}
|
||||
|
||||
return fetch(url, options).then((response) => {
|
||||
if (response.type == "opaque") {
|
||||
// For no-cors requests, return empty response
|
||||
return ""
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Not 2xx response");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user