Skip to content

Commit fa2cdfe

Browse files
committed
Try alternative route configuration for custom domain
- Changed from routes array to single route pattern - Added explicit CORS headers with origin validation - Added WAF bypass variables and compatibility flags - Enhanced OPTIONS request handling to bypass WAF restrictions
1 parent 443ef0f commit fa2cdfe

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/generateWorker.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,20 @@ export default {
6262
headers: request.headers.get("access-control-request-headers")
6363
});
6464
65+
// More explicit CORS headers to bypass WAF
66+
const origin = request.headers.get("origin");
67+
const allowedOrigins = ["https://bridge.katana.network", "https://api-polygon-tokens.staging.polygon.technology"];
68+
const allowOrigin = allowedOrigins.includes(origin) ? origin : "*";
69+
6570
return new Response(null, {
6671
status: 204,
6772
headers: {
68-
...corsHeaders,
69-
"Access-Control-Allow-Origin": request.headers.get("origin") || "*",
73+
"Access-Control-Allow-Origin": allowOrigin,
7074
"Access-Control-Allow-Methods": "GET, HEAD, POST, OPTIONS, PUT, DELETE",
71-
"Access-Control-Allow-Headers": request.headers.get("access-control-request-headers") || corsHeaders["Access-Control-Allow-Headers"],
72-
"Access-Control-Max-Age": "86400"
75+
"Access-Control-Allow-Headers": request.headers.get("access-control-request-headers") || "Content-Type, X-Requested-With, Authorization, Accept, Origin, DNT, X-CustomHeader, Keep-Alive, User-Agent, If-Modified-Since, Cache-Control, Content-Range, Range",
76+
"Access-Control-Max-Age": "86400",
77+
"Access-Control-Allow-Credentials": "false",
78+
"Vary": "Origin"
7379
}
7480
});
7581
}

wrangler.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ workers_dev = false
88
compatibility_flags = ["nodejs_compat"]
99

1010
[env.staging]
11-
routes = [
12-
"api-polygon-tokens.staging.polygon.technology/*"
13-
]
11+
route = "api-polygon-tokens.staging.polygon.technology/*"
12+
[env.staging.vars]
13+
CLOUDFLARE_WAF_BYPASS = "true"
14+
[env.staging.compatibility_flags]
15+
nodejs_compat = true
1416

1517
[env.production]
1618
routes = [

0 commit comments

Comments
 (0)