Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

migrate(docs): troubleshooting 31 (#30952)

Charisf4818474eca6
diff --git a/apps/docs/content/troubleshooting/performing-administration-tasks-on-the-server-side-with-the-servicerole-secret-BYM4Fa.mdx b/apps/docs/content/troubleshooting/performing-administration-tasks-on-the-server-side-with-the-servicerole-secret-BYM4Fa.mdx
new file mode 100644
index 00000000000..b4bb02e5f9e
--- /dev/null
+++ b/apps/docs/content/troubleshooting/performing-administration-tasks-on-the-server-side-with-the-servicerole-secret-BYM4Fa.mdx
@@ -0,0 +1,25 @@
+---
+title = "Performing administration tasks on the server side with the service_role secret"
+github_url = "https://github.com/orgs/supabase/discussions/15860"
+date_created = "2023-07-18T12:25:03+00:00"
+topics = ["auth", "platform"]
+keywords = ["service_role", "server", "security"]
+---
+
+By default, the auth-helpers/ssr do not permit the use of the `service_role` `secret`. This restriction is in place to prevent the accidental exposure of your `service_role` `secret` to the public. Since the auth-helpers/ssr function on both the server and client side, it becomes challenging to separate the key specifically for client-side usage.
+
+However, there is a solution. You can create a separate Supabase client using the `createClient` method from `@supabase/supabase-js` and provide it with the `service_role` `secret`. In a server environment, you will also need to disable certain properties to ensure proper functionality.
+
+By implementing this approach, you can safely utilize the `service_role` `secret` without compromising security or exposing sensitive information to the public.
+
+```ts
+import { createClient } from '@supabase/supabase-js'
+
+const supabase = createClient(supabaseUrl, serviceRoleSecret, {
+ auth: {
+ persistSession: false,
+ autoRefreshToken: false,
+ detectSessionInUrl: false,
+ },
+})
+```
diff --git a/apps/docs/content/troubleshooting/why-am-i-being-redirected-to-the-wrong-url-when-using-auth-redirectto-option-_vqIeO.mdx b/apps/docs/content/troubleshooting/why-am-i-being-redirected-to-the-wrong-url-when-using-auth-redirectto-option-_vqIeO.mdx
new file mode 100644
index 00000000000..d5d1cd6db67
--- /dev/null
+++ b/apps/docs/content/troubleshooting/why-am-i-being-redirected-to-the-wrong-url-when-using-auth-redirectto-option-_vqIeO.mdx
@@ -0,0 +1,14 @@
+---
+title = "Why am I being redirected to the wrong url when using auth redirectTo option?"
+github_url = "https://github.com/orgs/supabase/discussions/12946"
+date_created = "2023-03-10T17:15:10+00:00"
+topics = ["auth"]
+---
+
+Also, Why am I getting redirected to localhost instead of my production site URL?
+
+In order for the provided redirectTo option to work you must set the exact URL in the shown Redirect URL's setting.
+
+![image](/docs/img/troubleshooting/224379580-fa77bd31-bb58-47e6-90ce-64e140f32579.png)
+
+For more information on formats for redirect URL settings see the documentation here: https://supabase.com/docs/guides/auth/overview#redirect-urls-and-wildcards
diff --git a/apps/docs/content/troubleshooting/why-do-i-see-auth--api-requests-in-the-dashboard-my-app-has-no-users-CyadiO.mdx b/apps/docs/content/troubleshooting/why-do-i-see-auth--api-requests-in-the-dashboard-my-app-has-no-users-CyadiO.mdx
new file mode 100644
index 00000000000..4192febae45
--- /dev/null
+++ b/apps/docs/content/troubleshooting/why-do-i-see-auth--api-requests-in-the-dashboard-my-app-has-no-users-CyadiO.mdx
@@ -0,0 +1,19 @@
+---
+title = "Why do I see Auth & API requests in the dashboard? My app has no users"
+github_url = "https://github.com/orgs/supabase/discussions/21579"
+date_created = "2024-02-26T21:39:41+00:00"
+topics = ["auth", "platform", "database", "realtime", "functions"]
+keywords = ["dashboard", "health", "endpoints"]
+---
+
+The dashboard makes requests to the health endpoints of the supabase services (Database, Auth, Data API, Realtime, Edge Functions to ensure everything is working). These requests appear in the charts about your project:
+
+<img
+ width="1135"
+ alt="image"
+ src="https://github.com/supabase/supabase/assets/5036432/08b1c142-289c-46f3-ac21-38faad50ef8a"
+/>
+
+You can see these requests to the health endpoints from the log explorer here:
+
+https://supabase.com/dashboard/project/_/logs/edge-logs
diff --git a/apps/docs/content/troubleshooting/why-is-my-service-role-key-client-getting-rls-errors-or-not-returning-data-7_1K9z.mdx b/apps/docs/content/troubleshooting/why-is-my-service-role-key-client-getting-rls-errors-or-not-returning-data-7_1K9z.mdx
new file mode 100644
index 00000000000..41d2031e195
--- /dev/null
+++ b/apps/docs/content/troubleshooting/why-is-my-service-role-key-client-getting-rls-errors-or-not-returning-data-7_1K9z.mdx
@@ -0,0 +1,19 @@
+---
+title = "Why is my service role key client getting RLS errors or not returning data?"
+github_url = "https://github.com/orgs/supabase/discussions/30146"
+date_created = "2024-10-28T18:31:39+00:00"
+topics = ["auth", "database"]
+keywords = ["rls", "service_role", "authorization", "session", "apikey"]
+---
+
+A Supabase client with the Authorization header set to the service role apikey will ALWAYS bypass RLS. By default the Authorization header is the apikey used in createClient. If you are getting an RLS error then you have a user session getting into the client or you initialized with the anon key. RLS in enforced based on the Authorization header and not the apikey header.
+
+Three common cases of the createClient apikey being replaced by a user session/token:
+
+1. SSR client initialized with service role. The SSR clients are designed to share the user session from cookies. The user session will override the default apikey from createClient in the Authorization header. If you are using SSR, always create a separate server client using supabase-js directly for service role.
+
+2. Edge functions or other server code setting the Authorization header in createClient options directly to a user token/jwt. When you set the Authorization header directly that overrides the default action of using the apikey for the Authorization header.
+
+3. Server client initialized with service role using signUp to create a user or other auth functions. Many auth functions will return a user session to the client making the call. When that happens the apikey will be replaced by the user token/jwt in the Authorization header. If you are wanting to create a user in a service role client use admin.createUser() instead. Otherwise use a separate Supabase client for for service role from other actions.
+
+Also note that adding service_role in RLS policies does nothing. Service role will never run the policies to begin with.
diff --git a/apps/docs/content/troubleshooting/why-is-my-supabase-api-call-not-returning-PGzXw0.mdx b/apps/docs/content/troubleshooting/why-is-my-supabase-api-call-not-returning-PGzXw0.mdx
new file mode 100644
index 00000000000..0f08434a628
--- /dev/null
+++ b/apps/docs/content/troubleshooting/why-is-my-supabase-api-call-not-returning-PGzXw0.mdx
@@ -0,0 +1,13 @@
+---
+title = "Why is my supabase API call not returning?"
+github_url = "https://github.com/orgs/supabase/discussions/19058"
+date_created = "2023-11-17T22:39:54+00:00"
+topics = ["auth", "platform"]
+keywords = ["deadlock", "hang", "async"]
+---
+
+There is currently a bug in supabase-js which results in a deadlock if any async API call is made in onAuthStateChange code. If a call is made in the handler then the next Supabase call anywhere using that client will hang and not return.
+
+For now a workaround is needed until this is fixed.
+
+https://github.com/supabase/gotrue-js/issues/762#issuecomment-1780006492
diff --git a/apps/docs/public/img/troubleshooting/224379580-fa77bd31-bb58-47e6-90ce-64e140f32579.png b/apps/docs/public/img/troubleshooting/224379580-fa77bd31-bb58-47e6-90ce-64e140f32579.png
new file mode 100644
index 00000000000..f236805dbbc
Binary files /dev/null and b/apps/docs/public/img/troubleshooting/224379580-fa77bd31-bb58-47e6-90ce-64e140f32579.png differ