Cloudflare rewriting search parameters

I'm having some trouble with URL search parameters. Product hunt is sending visitors to my site with this URL: https://saymyname.how?ref=producthunt However, Cloudflare seems to be rewriting it to https://saymyname.how/ref=producthunt. How do I prevent that?
14 Replies
Chaika
Chaika7mo ago
That redirect is from your origin (the Pages app under), the CF-Cache-Status header gives it away You're using Functions? hmm
No description
Chaika
Chaika7mo ago
I see 2 301s 1 from https://saymyname.how?ref=producthunt to /ref=producthunt (from the function) and another from /ref=producthunt to https://saymyname.how (from CF - no cf-cache-status header)
JustinNoel
JustinNoel7mo ago
Yes I'm using how no and cloudflare pages functions. To solve the original problem, I added this redirect rule: https://saymyname.how?ref=producthunt => https://saymyname.how otherwise the users landed on a 404 page
Chaika
Chaika7mo ago
oh I see, but you have no idea why your function is doing the initial redirect stripping the ? tag? Using a specific framework?
JustinNoel
JustinNoel7mo ago
oh I see, but you have no idea why your function is doing the initial redirect stripping the ? tag?
I am using hono I don't see any thing in my code that is causing that.
Chaika
Chaika7mo ago
It looks like for any request to the root page with a query string, it strips the first character in the url/the ? in url
No description
Chaika
Chaika7mo ago
Doesn't happen on /login for example though, or if there's no query string
JustinNoel
JustinNoel7mo ago
Right. I taotally don't get that because my code doesn't do that. I'm going to ask this in the how no discord channel to.
Chaika
Chaika7mo ago
Do you have any special handling for the root page at all?
JustinNoel
JustinNoel7mo ago
This is my "catch-all" route:
/*
This needs to be the very last route as it's basically a wildcard that will
match any route off root
*/
app.all("/:customer-route-slug", async (c) => {
return customerRoute({ c });
});
/*
This needs to be the very last route as it's basically a wildcard that will
match any route off root
*/
app.all("/:customer-route-slug", async (c) => {
return customerRoute({ c });
});
theoretically, that shouldn't affect search parameters though. I found it! As usual, it's my fault. I have something special going on there with searches. Since my site has the search function disabled, I forgot all about it. thanks so much @Chaika and @Skye for jumping into help.
JustinNoel
JustinNoel7mo ago
It's fixed now! I still wish cloudflare didn't add that trailing slash to every url. https://saymyname.how/?ref=producthunt
Say My Name
Share the proper pronunciation of your name or learn how to pronounce a name correctly before meetings, interviews, podcasts, or conferences. Say My Name lets everyone record the proper pronunciation and story of their name in their OWN voice - no robotic or generic recordings.
Chaika
Chaika7mo ago
hmm what do you mean by trailing slash? talking about how https://saymyname.how?ref=producthunt becomes https://saymyname.how/?ref=producthunt in the browser? If so, that's just browser behavior. No such thing as an empty path, it's always / if empty
JustinNoel
JustinNoel7mo ago
Oh..... I didn't realize that. You're right: `https://duckduckgo.com/?q=test&ia=web"
test at DuckDuckGo
DuckDuckGo. Privacy, Simplified.
Chaika
Chaika7mo ago
lol yea Discord even beautifies the links and adds the slash if you don't include it
Want results from more Discord servers?
Add your server
More Posts
Some updates for @Queues users:Some updates for @Queues users: - We're working on landing HTTP Pull, which will allow you to poll Limit access to flexible images via worker?I want to only allow access to my images stored on cf images through my worker, but the issue is I wStreaming support 8k90 or 4k120? Both YT and IG support 4k60 maxHey does Cloudflare streaming support 8k90 or 4k120? Both YT and IG support 4k60 max. I want to provScript does not work with environmental variablesHi, I am using this function to get contact form submit data and send it via sendgrid. However, onceHi, could anyone explain me in simpleHi, could anyone explain me in simple terms (I would have put ELIF), why I am getting this error in What's the file structure for the drag-and-drop functionality look like?Been having trouble getting your static pages working. I have images, HTML, and CSS for multiple pagI think theres a scam page on your hostingsomeone is trying to scam me from this website -- https://rectificationsync.pages.dev/ I cannot finWebsite is super slow to load from China, anything i can do to improve it besides enterprise planSymptoms: I have a server hosted in Singapore and proxied by Cloudflare. It appears that users from Smart Placement and Service BindingsIs it possible to have a Worker that is edge-based/doesn't use Smart Placement that has a service bican you hot reload edge functions with next-on-pages?can you hot reload functions with next-on-pages? changing `page.tsx` changes the UI for me.. but do