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
That redirect is from your origin (the Pages app under), the CF-Cache-Status header gives it away
You're using Functions? hmm
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)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 pageoh I see, but you have no idea why your function is doing the initial redirect stripping the ? tag?
Using a specific framework?
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.
It looks like for any request to the root page with a query string, it strips the first character in the url/the
?
in urlDoesn't happen on /login for example though, or if there's no query string
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.
Do you have any special handling for the root page at all?
This is my "catch-all" route:
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.
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.
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 emptytest at DuckDuckGo
DuckDuckGo. Privacy, Simplified.
lol yea Discord even beautifies the links and adds the slash if you don't include it