Skip to content

Commit

Permalink
fix: now WAF bypass token header is forwarded
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytonline committed Jul 31, 2023
1 parent bee9ce2 commit 6d8bb70
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { parseURL } from 'ufo'
import etag from 'etag'
import { loadSourceImage } from './http'
import { decodeBase64Params, doPatternsMatchUrl, RemotePattern } from './utils'

const WAF_BYPASS_TOKEN_HEADER = 'X-Nf-Waf-Bypass-Token'

export interface IPXHandlerOptions extends Partial<IPXOptions> {
/**
* Path to cache directory
Expand Down Expand Up @@ -94,6 +97,13 @@ export function createIPXHandler ({
const requestHeaders: Record<string, string> = {
[SUBREQUEST_HEADER]: '1'
}

// This header is available to all lambdas that went through WAF
if (event.headers[WAF_BYPASS_TOKEN_HEADER]) {
requestHeaders[WAF_BYPASS_TOKEN_HEADER] =
event.headers[WAF_BYPASS_TOKEN_HEADER]
}

const isLocal = !id.startsWith('http://') && !id.startsWith('https://')
if (isLocal) {
const url = new URL(event.rawUrl)
Expand Down

0 comments on commit 6d8bb70

Please sign in to comment.