lifehackerhansol
lifehackerhansol
CDCloudflare Developers
Created by lifehackerhansol on 8/26/2024 in #workers-help
Worker is lowercasing URL using Response.redirect
Using this code:
async function redirect(request) {
const uri = request.url.replace(/^https:\/\/.*?\//gi, "/");
console.log(uri);
let url = "https://mirrors.lifehacker101.net/flashcard-archive/" + uri;
console.log(url);

return Response.redirect(url);
}
async function redirect(request) {
const uri = request.url.replace(/^https:\/\/.*?\//gi, "/");
console.log(uri);
let url = "https://mirrors.lifehacker101.net/flashcard-archive/" + uri;
console.log(url);

return Response.redirect(url);
}
it correctly logs:
/TEST.zip
https://mirrors.lifehacker101.net/flashcard-archive//TEST.zip
/TEST.zip
https://mirrors.lifehacker101.net/flashcard-archive//TEST.zip
However it is doing this instead:
alt-svc: h3=":443"; ma=86400
cf-ray: 8b95d70761e72d54-yvr
connection: keep-alive
content-length: 0
date: mon, 26 aug 2024 18:21:09 gmt
location: https://mirrors.lifehacker101.net/flashcard-archive//test.zip
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=f6ywic6ivn7gxmcc5of0ttz8mshxbgs3x1uxhauebsfxf8pjmihymutle5mil4jijka6g1lz0g9%2fzrm8fk2phzsnmbin3onytxadmywve7vreftyi07xfrair4y8bcv1ande8qvoqlulvu8ai0mmt%2ft8zmc5eryp7ci5lw550doptvwkumzwml%2fwfb9g"}],"group":"cf-nel","max_age":604800}
server: cloudflare
vary: accept-encoding
alt-svc: h3=":443"; ma=86400
cf-ray: 8b95d70761e72d54-yvr
connection: keep-alive
content-length: 0
date: mon, 26 aug 2024 18:21:09 gmt
location: https://mirrors.lifehacker101.net/flashcard-archive//test.zip
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=f6ywic6ivn7gxmcc5of0ttz8mshxbgs3x1uxhauebsfxf8pjmihymutle5mil4jijka6g1lz0g9%2fzrm8fk2phzsnmbin3onytxadmywve7vreftyi07xfrair4y8bcv1ande8qvoqlulvu8ai0mmt%2ft8zmc5eryp7ci5lw550doptvwkumzwml%2fwfb9g"}],"group":"cf-nel","max_age":604800}
server: cloudflare
vary: accept-encoding
This causes 404 on the target location's web server. Is there something going on that I don't know about causing this?
4 replies
CDCloudflare Developers
Created by lifehackerhansol on 10/18/2023 in #pages-help
How to have exact opposite behaviour of CF Pages pretty URL??
https://wiki-8j2.pages.dev https://github.com/flashcarts/wiki I've found that Cloudflare Pages' built in pretty URL system will rewrite links to .html to remove this suffix. I want to have the exact opposite: if a user accesses the URL via pretty URL format, I want it to automatically append .html. I would rather user have the full path; the only reason the pretty URL is relevant for me is to make internal linking in markdown not a huge PITA to do. While I haven't tried it, I am naively thinking that if I make use of a _redirects file for this, it would cause an infinite loop of _redirects redirecting to .html and CF Pages 308-ing to non-.html. Is there a way to get around this?
2 replies
CDCloudflare Developers
Created by lifehackerhansol on 8/29/2023 in #general-help
WAF on non-known bots trigger on a web browser GET request
While playing around with Cloudflare security rules for R2, I came across the Known Bots flag. I've tested this in a few angles, and it appears that doing any action against (not cf.client.bot) seems to also trigger on Firefox and Microsoft Edge. Some questions for that: - Are plain ol' browsers also considered bots? - If I am using a public bucket, do I have no choice but to let bots fly so that a standard web browser can do its job? (and sacrifice free R2 ops count for this?)
3 replies