79656039

Date: 2025-06-06 14:08:22
Score: 0.5
Natty:
Report link

I ran into the same issue when integrating Clerk with Vite and react-router-dom under a custom base path like /admin. The key here is to ensure that all parts of the app — Vite, React Router, and Clerk — have consistent understanding of the base path, and avoid double-prefixing in redirects.

✅ The Root Cause

When using Google OAuth, Clerk redirects using the public base URL configured in your Clerk dashboard or environment. If VITE_CLERK_SIGN_IN_REDIRECT_URL is set to dashboard, Clerk assumes the full redirect should be /admin/dashboard. But if you already set your Vite base as /admin, and then also include /admin in the Clerk redirect, you’ll end up with /admin/admin/dashboard — which causes the 404.

🛠️ Working Solution

Update your .env with the relative path only — Clerk already knows to prepend the base:

env

VITE_CLERK_SIGN_IN_REDIRECT_URL=/dashboard VITE_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/dashboard

Notice the leading /, but do not include /admin here.

📍Also Important

Reasons:
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: rkoots