Finish ip fetching

This commit is contained in:
mrjvs
2023-12-20 14:37:34 +01:00
parent ed4d8826ce
commit 9ef1467ee1
2 changed files with 10 additions and 2 deletions

View File

@@ -1,5 +1,10 @@
import { EventHandlerRequest, H3Event } from 'h3';
export function getIp(_event: H3Event<EventHandlerRequest>) {
return 'not-a-real-ip'; // TODO cross platform IP
export function getIp(event: H3Event<EventHandlerRequest>) {
const value = getHeader(event, 'CF-Connecting-IP');
if (!value)
throw new Error(
'Ip header not found, turnstile only works on cloudflare workers',
);
return value;
}