Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Fix OAuth consent page under hash routing

Claude18228fb7fea1
diff --git a/doc/src/content/docs/developers/supabase-configuration.mdx b/doc/src/content/docs/developers/supabase-configuration.mdx
index b96356dc..90f9b9a0 100644
--- a/doc/src/content/docs/developers/supabase-configuration.mdx
+++ b/doc/src/content/docs/developers/supabase-configuration.mdx
@@ -172,6 +172,12 @@ When using a remote Supabase instance, you need to configure the callback URL as
If you host Atomic CRM under the `https://example.com/atomic-crm/` URL, the callback URL should be `https://example.com/atomic-crm/auth-callback.html`.
+## Setting The OAuth Consent Page
+
+The [MCP server](../../users/mcp-server) authenticates AI assistants with the Supabase OAuth 2.1 server, which redirects users to a consent page hosted by the frontend. With a local Supabase instance, this is already configured in `supabase/config.toml`.
+
+With a remote Supabase instance, go to **Authentication** > **OAuth Server** in the project dashboard and set the **Authorization Path** to `/oauth-consent.html`. This static page forwards to the in-app consent route, as the app uses hash-based routing.
+
## Customizing Email Templates
Atomic CRM uses Supabase to send authentication-related emails (confirm signup, reset password, etc).
diff --git a/public/oauth-consent.html b/public/oauth-consent.html
new file mode 100644
index 00000000..8f4cbdc0
--- /dev/null
+++ b/public/oauth-consent.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title>Atomic CRM</title>
+ </head>
+ <body>
+ <script>
+ // Supabase Auth redirects OAuth consent requests to a plain path, but
+ // the app uses hash routing: forward to the consent route, keeping
+ // the authorization_id query parameter.
+ window.location.replace(
+ `./#/oauth/consent${window.location.search}`
+ );
+ </script>
+ </body>
+</html>
diff --git a/src/components/supabase/oauth-consent-page.tsx b/src/components/supabase/oauth-consent-page.tsx
index 779c56fa..a040e148 100644
--- a/src/components/supabase/oauth-consent-page.tsx
+++ b/src/components/supabase/oauth-consent-page.tsx
@@ -53,9 +53,13 @@ export function OAuthConsentPage() {
try {
await authProvider.checkAuth({});
} catch {
- navigate(
- `/login?redirect=/oauth/consent?authorization_id=${authorizationId}`,
- );
+ // useLogin sends the user back to this location state after login
+ navigate("/login", {
+ state: {
+ nextPathname: OAuthConsentPage.path,
+ nextSearch: `?authorization_id=${encodeURIComponent(authorizationId)}`,
+ },
+ });
return;
}
diff --git a/supabase/config.toml b/supabase/config.toml
index 0b28d58d..4ddfd286 100644
--- a/supabase/config.toml
+++ b/supabase/config.toml
@@ -86,7 +86,7 @@ signing_keys_path = "./signing_keys.json"
[auth.oauth_server]
enabled = true
-authorization_url_path = "/oauth/consent"
+authorization_url_path = "/oauth-consent.html"
allow_dynamic_registration = true
[auth.email]