website icon indicating copy to clipboard operation
website copied to clipboard

feat: redirect known users

Open ruf-io opened this issue 9 months ago • 4 comments

This is testing UX of redirecting known (have ajs_user_id) users directly to console.

[!TIP] To make yourself a "known user" in the Vercel preview, open up web console and run document.cookie = 'ajs_user_id=test'

How it works

  1. Redirect from neon.tech to console.neon.tech for anyone who has the ajs_user_id cookie set (this is a cookie that holds the user's platform UUID and is set AFTER they log in) https://github.com/neondatabase/website/blob/da8b9b27455beb830c43dfbe5283a31187af2786/next.config.js#L107-L123

  2. Create a new clone of the homepage at neon.tech/home that is blocked from search engine indexes https://github.com/neondatabase/website/blob/da8b9b27455beb830c43dfbe5283a31187af2786/src/app/home/page.jsx#L1-L37

  3. For visitors that have ajs_user_id set, make internal homepage links route to neon.tech/home instead of neon.tech Example: https://github.com/neondatabase/website/blob/da8b9b27455beb830c43dfbe5283a31187af2786/src/components/pages/404/hero/hero.jsx#L25 and https://github.com/neondatabase/website/blob/da8b9b27455beb830c43dfbe5283a31187af2786/src/utils/get-homepage-route.js#L1-L5

  4. For visitors that have ajs_user_id, replace the "Sign Up" and "Log In" buttons with "Go to Console" image

ruf-io avatar May 03 '24 13:05 ruf-io

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
neon-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2024 0:00am

vercel[bot] avatar May 03 '24 13:05 vercel[bot]

I like this. I think the main thing I notice is that docs, blog, changelog links are down on the left. If I was going to neon.tech for a blog post I don't think I'd look there. When I compare to Vercel the top bar has those links as well as the bottom row. I don't think we need to move quickly to make a change to what they have but it's the first thing I noticed.

clarkbw avatar May 05 '24 19:05 clarkbw

Hi @ruf-io,

The PR looks great! Could we refactor step 3 slightly to utilize the constant LINKS.home? I believe there are two potential options (or a combination of both):

  1. Add the property home: getHomepageRoute() to constant.js.
  2. Implement a Next.js redirect from / to /home in page.jsx when a cookie is present.

I believe these changes would not only help prevent users with cookies from accessing the / page but also simplify the management of home page links throughout our project.

americano98 avatar May 06 '24 14:05 americano98

@americano98 Want to take over the PR and make the necessary changes?

Just hold off on merging. I need to get proper buy-in internally first.

ruf-io avatar May 07 '24 10:05 ruf-io

@ruf-io I made some changes. Now, the workflow is as follows:

When a user visits the / page, if they have a cookie, we check the headers to determine where the user came from. If it's an internal transition, we redirect them to /home. If it's an external transition, we redirect them to console.neon.tech.

This way, we can keep all links pointing to the index as /. And thanks to server actions, we will generate the UI header on the server side

americano98 avatar May 22 '24 12:05 americano98