diff --git a/docs/USAGE.md b/docs/USAGE.md index 36149314..bededb42 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -745,22 +745,22 @@ webhook_enabled = "true" webhook_public_url = "" ``` -Setting `webhook_enabled` to `true` enables the webhook in 'monitor' mode. The onedrive process will listen for incoming updates at a configurable endpoint, which defaults to `0.0.0.0:8888`. The `webhook_public_url` must be set to an public-facing url for Microsoft to send updates to your webhook. If your host is directly exposed to the Internet, the `webhook_public_url` can be set to `http://:8888/` to match the default endpoint. However, the recommended approach is to configure a reverse proxy like nginx. +Setting `webhook_enabled` to `true` enables the webhook in 'monitor' mode. The onedrive process will listen for incoming updates at a configurable endpoint, which defaults to `0.0.0.0:8888`. The `webhook_public_url` must be set to an public-facing url for Microsoft to send updates to your webhook. If your host is directly exposed to the Internet, the `webhook_public_url` can be set to `http://:8888/` to match the default endpoint. However, the recommended approach is to configure a reverse proxy like nginx. + +**Note:** A valid HTTPS certificate is required for your public-facing URL if using nginx. For example, below is a nginx config snippet to proxy traffic into the webhook: ``` -http { - server { - listen 80; - location /webhooks/onedrive { - proxy_pass http://127.0.0.1:8888; - } - } +server { + listen 80; + location /webhooks/onedrive { + proxy_pass http://127.0.0.1:8888; + } } ``` -With nginx running, you can configure `webhook_public_url` to `http:///webhooks/onedrive`. +With nginx running, you can configure `webhook_public_url` to `https:///webhooks/onedrive`. ### More webhook configuration options diff --git a/src/onedrive.d b/src/onedrive.d index f811c4eb..6c351bff 100644 --- a/src/onedrive.d +++ b/src/onedrive.d @@ -1004,7 +1004,17 @@ final class OneDriveApi "clientState": randomUUID().toString() ]; http.addRequestHeader("Content-Type", "application/json"); - JSONValue response = post(url, request.toString()); + JSONValue response; + + try { + response = post(url, request.toString()); + } catch (OneDriveException e) { + displayOneDriveErrorMessage(e.msg, getFunctionName!({})); + + // We need to exit here, user needs to fix issue + log.error("ERROR: Unable to initialize subscriptions for updates. Please fix this issue."); + exit(-1); + } // Save important subscription metadata including id and expiration subscriptionId = response["id"].str;