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 24 (#30947)

Charis42efba186b72
diff --git a/apps/docs/content/troubleshooting/how-do-you-troubleshoot-nextjs---supabase-auth-issues-riMCZV.mdx b/apps/docs/content/troubleshooting/how-do-you-troubleshoot-nextjs---supabase-auth-issues-riMCZV.mdx
new file mode 100644
index 00000000000..dcb2b077963
--- /dev/null
+++ b/apps/docs/content/troubleshooting/how-do-you-troubleshoot-nextjs---supabase-auth-issues-riMCZV.mdx
@@ -0,0 +1,33 @@
+---
+title = "How do you troubleshoot NextJS - Supabase Auth issues?"
+github_url = "https://github.com/orgs/supabase/discussions/27606"
+date_created = "2024-06-28T03:26:44+00:00"
+topics = ["auth"]
+keywords = ["NextJS", "SSR", "authentication", "client"]
+---
+
+Authentication is hard. SSR is harder. At Supabase, we try to address these together by providing`@supabase/ssr` package to help implement authentication with Supabase conveniently. While I’m targeting to address NextJS-related issues, you can probably apply these concepts to other SSR frameworks such as Nuxt, SvelteKit, and Remix. This is a living document, and we plan to update it regularly as NextJS and its APIs + `@supabase/ssr` evolve.
+
+If you are experiencing issues with Supabase Auth and SSR, the following checklist will help you troubleshoot the issues.
+
+✅ You’re on the latest version of `@supabase/ssr` package. Note that the `@supabase/auth-helpers` package is being deprecated, and all the bug fixes and feature releases will be focused on the `@supabase/ssr` package.
+✅ Do you have all the client utility functions implemented? This way, you can easily import them into your components that need access to Supabase auth functions. Make sure to follow the [guide available here](https://supabase.com/docs/guides/auth/server-side/creating-a-client?queryGroups=framework&framework=nextjs&queryGroups=environment&environment=client-component#creating-a-client) carefully to avoid running into unexpected errors.
+✅ Do you have the `middleware.ts` file correctly implemented? This lets you refresh expired sessions before loading server components that require a user session for authorization.
+
+This documentation will help you validate that you’re on the correct path.
+
+- Setting up Server-Side Auth for Next.js - https://supabase.com/docs/guides/auth/server-side/nextjs?queryGroups=router&router=app
+- SSR advanced guide - https://supabase.com/docs/guides/auth/server-side/advanced-guide
+- Creating a Supabase client for SSR - https://supabase.com/docs/guides/auth/server-side/creating-a-client?queryGroups=framework&framework=nextjs&queryGroups=environment&environment=middleware
+
+Another way to identify any potential issues with your code is to compare it with the Supabase NextJS quickstart. Use the command `npx create-next-app -e with-supabase` to download a copy to your local machine of the quickstart application.
+
+Our YouTube channel has great videos to help you implement Supabase Auth with Next.js.
+
+- The Right Way to do Auth with the Next.js App Router - https://youtu.be/v6UvgfSIjQ0?si=TBUN9dD4pmjRg78a
+
+Also, please take some time to get familiar with some concepts on authentication with NextJS, such as https://nextjs.org/docs/app/building-your-application/authentication.
+
+We know your requirements vary, and you might run into an edge case. In that scenario, please use our amazing community channels ([GitHub](https://github.com/orgs/supabase/discussions), [Discord](https://discord.gg/rxTfewPvys)) to get help troubleshooting the issue. You can post your issues to the `@supabase/ssr` [GitHub repo](https://github.com/supabase/ssr/issues). We always welcome your contributions!
+
+If none of the above works, please don’t hesitate to reach out to [Supabase support](https://supabase.help); consider adding more information, such as your use case, code snippets, a copy of your `package.json`, `middleware.ts` and a HAR file, to help the support team triage your issue.
diff --git a/apps/docs/content/troubleshooting/importing-stripe-or-other-modules-from-esmsh-on-deno-edge-functions-throws-an-error-TmbB5p.mdx b/apps/docs/content/troubleshooting/importing-stripe-or-other-modules-from-esmsh-on-deno-edge-functions-throws-an-error-TmbB5p.mdx
new file mode 100644
index 00000000000..e32212f4842
--- /dev/null
+++ b/apps/docs/content/troubleshooting/importing-stripe-or-other-modules-from-esmsh-on-deno-edge-functions-throws-an-error-TmbB5p.mdx
@@ -0,0 +1,13 @@
+---
+title = "Importing Stripe or other modules from esm.sh on Deno Edge Functions throws an error"
+github_url = "https://github.com/orgs/supabase/discussions/14303"
+date_created = "2023-05-12T01:30:31+00:00"
+topics = ["functions"]
+keywords = ["import", "module", "esm"]
+---
+
+Try adding `?target=deno` to the import path of the module. For Stripe, the updated import would be:
+
+```
+import Stripe from "https://esm.sh/[email protected]?target=deno";
+```
diff --git a/apps/docs/content/troubleshooting/inspecting-edge-function-environment-variables-wg5qOQ.mdx b/apps/docs/content/troubleshooting/inspecting-edge-function-environment-variables-wg5qOQ.mdx
new file mode 100644
index 00000000000..d9c5e69dcf8
--- /dev/null
+++ b/apps/docs/content/troubleshooting/inspecting-edge-function-environment-variables-wg5qOQ.mdx
@@ -0,0 +1,70 @@
+---
+title = "Inspecting edge function environment variables"
+github_url = "https://github.com/orgs/supabase/discussions/27139"
+date_created = "2024-06-09T18:44:40+00:00"
+topics = ["functions", "cli"]
+keywords = ["logging", "environment", "variables", "secrets", "docker"]
+
+[api]
+cli = ["supabase-init", "supabase-secrets-set", "supabase-secrets-list"]
+---
+
+Sometimes it can be informative to log values from your Edge Functions. This walks you through the process of logging environment variables for inspection, but it can be generalized for all logging.
+
+**Steps:**
+
+1. enable docker
+
+2. Create a local Supabase project
+
+```bash
+npx supabase init
+```
+
+3. create a .env file in the supabase folder
+
+```bash
+echo "MY_NAME=Some_name" >> ./supabase/.env
+```
+
+4. deploy the newly added secret
+
+```bash
+npx supabase secrets set --env-file ./supabase/.env --project-ref <PROJECT REF>
+```
+
+5. Run the following CLI command to check secrets:
+
+```
+npx supabase secrets list
+```
+
+For security reasons, it is not advised to log secrets, but you can log a truncated version just for the reassurance that they're being updated:
+
+```typescript
+//logs the function call and the secrets
+console.log('Hello from Functions!')
+
+//custom secret
+console.log('logging custom secret', Deno.env.get('MY_NAME'))
+
+// default secrets
+console.log('logging SUPABASE_URL:', Deno.env.get('SUPABASE_URL').slice(0, 15))
+
+Deno.serve(async (req) => {
+ const { name } = await req.json()
+ const data = {
+ message: `Hello ${name}!`,
+ }
+
+ return new Response(JSON.stringify(data), { headers: { 'Content-Type': 'application/json' } })
+})
+```
+
+After calling your function, you can check your [edge function logs](https://supabase.com/dashboard/project/_/functions/hello-world/logs?s=logging) to observe the logged values. It should look something like this:
+
+> Note: search filters are case sensitive and must be present in the event message.
+
+![image](/docs/img/troubleshooting/a360b417-e0cc-4706-8df4-89af63dcdc70.png)
+
+> Note: excessively long JSON logs may be truncated. If this occurs, use the [JSON.stringify()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) function to convert the JSON object into text. You can then copy and paste the log into a [JSON beautifier.](https://jsonformatter.org/)
diff --git a/apps/docs/content/troubleshooting/nextjs-1314-stale-data-when-changing-rls-or-table-data-85b8oQ.mdx b/apps/docs/content/troubleshooting/nextjs-1314-stale-data-when-changing-rls-or-table-data-85b8oQ.mdx
new file mode 100644
index 00000000000..ec6b4bca08d
--- /dev/null
+++ b/apps/docs/content/troubleshooting/nextjs-1314-stale-data-when-changing-rls-or-table-data-85b8oQ.mdx
@@ -0,0 +1,20 @@
+---
+title = "Next.js 13/14 stale data when changing RLS or table data."
+github_url = "https://github.com/orgs/supabase/discussions/19084"
+date_created = "2023-11-19T19:33:06+00:00"
+topics = ["auth", "platform"]
+keywords = ["cache", "rls", "next.js"]
+---
+
+Next.js caches urls in certain cases. This is causing users to lose lots of time debugging early on with RLS changes. Changing the table data in the UI will also not be returned in these cases.
+
+You can look at the Dashboard API Edge log to see if the request is making it to Supabase.
+Another way to check if the url caching is impacting you is to change `.select('*')` to `.select('colname')` or change column names. This would bust the next.js cache.
+
+Users have suggested the following three options to turn off the caching, but please refer to next.js docs as needed.
+
+`export const dynamic = 'force-dynamic'; // no caching`
+or
+`export const fetchCache = 'force-no-store' // to page.js`
+or
+`export const revalidate = 0 `
diff --git a/apps/docs/public/img/troubleshooting/a360b417-e0cc-4706-8df4-89af63dcdc70.png b/apps/docs/public/img/troubleshooting/a360b417-e0cc-4706-8df4-89af63dcdc70.png
new file mode 100644
index 00000000000..c8a0bebbf7a
Binary files /dev/null and b/apps/docs/public/img/troubleshooting/a360b417-e0cc-4706-8df4-89af63dcdc70.png differ