Cloudflare
Any changes to these workers should be done in the linked file(s) and should not be done via console unless it's for testing a change before propogating it to source code.
CORS & CDN
A cloudflare worker is deployed at farmto.com/api/v2/*
which all front end requests are proxied through to before hitting our API. The worker lives in the front end repo.
The deployment of it is handled by the existing front end deploy-cloudflare-workers
workflow. For it to pick up the cloudflare worker, a single entry has been added in the config.json file.
Ping & maintenance mode.
A cloudflare worker is deployed at ping.farmto.com/v2/* *
which the front end pings on an interval to see if the app is in maintenance mode. It returns a flag to indicate if it does, and provides a IP bypass for the maintenance.
KV (Database changes)
The whitelist of IP and status of whether maintenance mode is enabled or not is data driven. Two records have been added to the Cloudflare KV
stores (Workers > KV in the console).
To put the app in maintenance mode or bypass an IP, an update of these records is needed to be done, and is to be done manually via the console.
v2MaintenanceConfig:
{
"client": {
"inventory": {
"enabled": false
}
},
"bypassed": false,
"message": "Dev API logins are broken, working on a fix.",
"resolvedByDateUTC": "2021-08-27T16:00:00Z"
}
The above is the value set for the v2MaintenanceConfig
key. Followed the convention of the v1. To put app in maintenance mode, set the enabled
flag to true
, and set a message
for end users and an estimated resolved by timestamp. The client will then display a maintenance screen.
v2MaintenanceWhitelist:
[
{
"ip": "82.22.100.209",
"description": "Alex home",
"active": false
},
{
"ip": "88.98.74.136",
"description": "Stansted office",
"active": false
},
{
"ip": "82.47.213.4",
"description": "Ibrahim home",
"active": true
}
]
The above is the value set for the v2MaintenanceWhitelist
key in dev. The following IPs will skip any maintenance screen. You can append an entry to this as needed.