eo.clientIpプロパティを通じてクライアントIPを取得し、JSON形式のデータに組み立ててクライアントに応答することで、エッジ関数を使用したクライアントIPの取得を実現しています。function handleRequest(request) {// request.eo.clientIp を使用してクライアントIPを取得します。const ip = request.eo.clientIp || '';// JSONデータを応答します。return new Response(JSON.stringify({ ip }), {headers: { 'content-type': 'application/json' },});}addEventListener('fetch', event => {event.respondWith(handleRequest(event.request));});

フィードバック