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