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
Chaika13mo 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
Chaika13mo 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
JustinNoelOP13mo 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
Chaika13mo 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
JustinNoelOP13mo 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
Chaika13mo 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
Chaika13mo ago
Doesn't happen on /login for example though, or if there's no query string
JustinNoel
JustinNoelOP13mo 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
Chaika13mo ago
Do you have any special handling for the root page at all?
JustinNoel
JustinNoelOP13mo 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
JustinNoelOP13mo 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
Chaika13mo 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
JustinNoelOP13mo ago
Oh..... I didn't realize that. You're right: `https://duckduckgo.com/?q=test&ia=web"
test at DuckDuckGo
DuckDuckGo. Privacy, Simplified.
Chaika
Chaika13mo 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