Skip to content

Commit

Permalink
Finish ip fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjvs committed Dec 20, 2023
1 parent ed4d882 commit 9ef1467
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Read the docs at https://docs.movie-web.app/proxy
- bypass CORS - always allows browser to send requests through it
- secure it with turnstile - prevent bots from using your proxy

> [!WARNING]
> Turnstile integration only works properly with cloudflare workers as platform
### supported platforms:
- cloudflare workers
- AWS lambda
Expand Down
9 changes: 7 additions & 2 deletions src/utils/ip.ts
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 9ef1467

Please sign in to comment.