Hey everyone,
I have a use case where I have a route, just call it /posts for sake of argument, and I want it to accept a date parameter like this:
/posts?date=2025-10-18
I have some logic on the page that changes depending on if the given date is in the past, future, or is "today". I want "today" to be relative to the user's timezone, so "today" is valid as long as the passed in date is "today" somewhere in the world at the time it's passed in (between UTC-12 and UTC+14). The validation of the date of course needs to happen on the server, otherwise the user could change their computer clock dramatically and "time travel".
Furthermore, if you visit /posts without a date, I'd like to redirect you and pass the current day in (according to your timezone). I can't do this part on the server because if the server runs in UTC and you visit from UTC-12, it's possible today for you is 1 day behind the server, and I want to pass your date in, not the server's date.
So as of right this moment, if I visit /posts, it would redirect me to /posts?date=2025-01-20. Then the server would validate that 2025-01-20 is "today" somewhere in the world.
My question is, how do I safely do this? Since Start is isomorphic by default, I'm having a hard time telling if I'm using a client or server value. I've tried some of the createClientOnlyFn and createServerOnlyFn business, but I think something is wrong in my logic cause the page will crash sometimes due to the server calling the client one, etc.