Skip to content

Commit 3b93190

Browse files
authored
Allow passing "cf" to proxy (#13)
1 parent 6d97fed commit 3b93190

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/proxy/proxy.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { HeaderChanges, patchHeaders, patchRequest } from '../common/patch';
2-
import { FetchEvent, ServeFunction } from '../types';
2+
import { FetchEvent, FetchCFOptions, ServeFunction } from '../types';
33

44
export type GetEndpoint = (req?: Request) => URL;
55

@@ -8,6 +8,7 @@ type CustomHeaders = (req: Request) => HeaderChanges;
88
export interface ProxyOptions {
99
host?: 'original' | 'xforwarded';
1010
headers?: CustomHeaders;
11+
cf?: FetchCFOptions;
1112
}
1213

1314
const DEFAULT_OPTIONS: ProxyOptions = {
@@ -40,6 +41,7 @@ export function proxy(
4041
const response = await fetch(upstreamRequest, {
4142
redirect: 'manual',
4243
cf: {
44+
...(opts.cf || {}),
4345
resolveOverride:
4446
opts.host === 'original' ? endpoint.hostname : undefined
4547
}

src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ export interface FetchEvent extends Event {
66
respondWith(r: Promise<Response> | Response): Promise<Response>;
77
waitUntil(p: Promise<any>): void;
88
}
9+
10+
export interface FetchCFOptions {
11+
cacheEverything?: boolean;
12+
}

0 commit comments

Comments
 (0)