Cloudflare Workers Request Properties
When using the cloudflare_workers
package, you can access a number of request properties about the incoming request, such as the users geolocation and IP address via the cf
property:
import 'package:cloudflare_workers/cloudflare_workers.dart';
void main() {
CloudflareWorkers(fetch: (request, env, ctx) {
print('IP Adress: ${request.cf.ipAddress}');
print('City: ${request.cf.city}');
print('Country: ${request.cf.country}');
print('Region: ${request.cf.region}');
print('Postal Code: ${request.cf.postalCode}');
print('Latitude: ${request.cf.latitude}');
print('Longitude: ${request.cf.longitude}');
return Response("Hello...");
});
}