diff --git a/README.md b/README.md index 1a2ad1a68..160ae50d1 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ You can either deploy with **Cloudflare Deploy Button** using GitHub Actions or expectStatus: 200 # operational status, default=200 followRedirect: false # should fetch follow redirects, default=false linkable: false # should the titles be links to the service, default=true + withCredentials: false # specify if authentication is needed, set as false when not required + bearer: 'dXNlcjpwYXNz' # base64 encoded string of `username:password`, required if authentication is supported ``` 5. Push to `main` branch to trigger the deployment diff --git a/config.yaml b/config.yaml index ec7ca89a0..4ec02e9b3 100644 --- a/config.yaml +++ b/config.yaml @@ -23,6 +23,8 @@ monitors: expectStatus: 200 # operational status, default=200 followRedirect: false # should fetch follow redirects, default=false linkable: false # allows the title to be a link, default=true + withCredentials: false # specify if authentication is needed, set as false when not required + bearer: 'dXNlcjpwYXNz' # base64 encoded string of `username:password`, required if authentication is supported - id: www-cloudflare-com name: www.cloudflare.com diff --git a/src/functions/cronTrigger.js b/src/functions/cronTrigger.js index 671f1a310..865ec92ab 100644 --- a/src/functions/cronTrigger.js +++ b/src/functions/cronTrigger.js @@ -45,8 +45,10 @@ export async function processCronTrigger(event) { const init = { method: monitor.method || 'GET', redirect: monitor.followRedirect ? 'follow' : 'manual', + withCredentials: monitor.withCredentials, headers: { 'User-Agent': config.settings.user_agent || 'cf-worker-status-page', + 'Authorization': monitor.withCredentials ? ('Basic ' + monitor.bearer) : '', }, }