YN
05/24/2023, 7:00 AMdivby0
05/24/2023, 8:25 AMRazvan
05/24/2023, 8:53 AMhttps://cdn.discordapp.com/attachments/779390076219686943/1110852947421712444/image.png▾
Cyb3r-Jok3
05/24/2023, 11:14 AMbanbanboi
05/24/2023, 12:32 PMhttps://cdn.discordapp.com/attachments/779390076219686943/1110908261160460391/image.png▾
HardAtWork
05/24/2023, 12:34 PMOPTIONS
requests?banbanboi
05/24/2023, 12:35 PMHardAtWork
05/24/2023, 12:35 PMOPTIONS
request, which fails.banbanboi
05/24/2023, 12:38 PMhttps://cdn.discordapp.com/attachments/779390076219686943/1110909744136343552/image.png▾
HardAtWork
05/24/2023, 12:39 PMOPTIONS
request, irrespective of your Access-Control-Allow-Methods
. If you don't handle that in your Worker, then the entire thing failsbanbanboi
05/24/2023, 12:41 PMbanbanboi
05/24/2023, 12:41 PMLiberator
05/24/2023, 12:54 PMBenParr
05/24/2023, 12:57 PMecho "${{ parameters.cfAccessClientId }}" | npx wrangler secret put cfAccessClientId
echo "${{ parameters.cfAccessClientSecret }}" | npx wrangler secret put cfAccessClientSecret
if I set secrets like this, I can return them in response and they show... But I am not able to use them in a request to bypass cloudflare zero trust.... however if I set them as env variables when deploying like this npx wrangler deploy `
--var cfAccessClientId:"${{ parameters.cfAccessClientId }}" `
--var cfAccessClientSecret:"${{ parameters.cfAccessClientSecret }}"
it works absolutely fine...... how is this possible??BenParr
05/24/2023, 1:03 PMCyb3r-Jok3
05/24/2023, 1:35 PMLiberator
05/24/2023, 1:52 PMCyb3r-Jok3
05/24/2023, 2:06 PMLiberator
05/24/2023, 2:07 PMBenParr
05/24/2023, 2:08 PM\ufeff
was being added to the front. No idea why thoIdkWhatever69
05/24/2023, 2:50 PMhttps://cdn.discordapp.com/attachments/779390076219686943/1110942956573175818/Screenshot_2023-05-24_at_8.20.14_PM.png▾
IdkWhatever69
05/24/2023, 2:50 PMIdkWhatever69
05/24/2023, 2:51 PMhttps://cdn.discordapp.com/attachments/779390076219686943/1110943112668401796/Screenshot_2023-05-24_at_8.21.09_PM.png▾
sathoro
05/24/2023, 2:52 PMsathoro
05/24/2023, 2:53 PMIdkWhatever69
05/24/2023, 3:08 PMbanbanboi
05/24/2023, 3:08 PMsathoro
05/24/2023, 3:08 PMsathoro
05/24/2023, 3:11 PMjs
const enableCORS = (request, response) => {
const origin = request.headers.get("origin") || "";
const isAllowedOrigin =
origin === "http://localhost:3000" ||
origin.endsWith(".example.com");
if (isAllowedOrigin) {
for (const [key, value] of Object.entries({
"Access-Control-Allow-Origin": origin,
"Access-Control-Allow-Methods": "POST, DELETE, GET, OPTIONS",
"Access-Control-Allow-Headers": "*",
})) {
response.headers.append(key, value);
}
}
return response;
};
and in my route handling I have a simple
js
if (request.method === "OPTIONS") {
return new Response("ok");
}
and this is what ties it together...
js
const response = await handleRequest(request, env, context, sentry);
return enableCORS(request, response);
banbanboi
05/24/2023, 3:14 PM