Skip to content

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

chore: add wildcard redirect docs.

thorwebdev9b82d50e42b2
diff --git a/apps/docs/docs/guides/auth.mdx b/apps/docs/docs/guides/auth.mdx
index 1d60ab88fbb..95dd1dbf3ad 100644
--- a/apps/docs/docs/guides/auth.mdx
+++ b/apps/docs/docs/guides/auth.mdx
@@ -49,6 +49,43 @@ You can enable third-party providers with the click of a button by navigating to
![OAuth Logins.](/docs/img/supabase-oauth-logins.png)
+### Redirect URLs and wildcards
+
+When using third-party providers the [Supabase client library](/docs/reference/javascript/auth-signinwithoauth#sign-in-using-a-third-party-provider-with-redirect) will redirect the user to the provider. When the third-party provider successfully authenticates the user, the provider will redirect the user to the Supabase Auth callback URL, from where they will be further redirected to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](/docs/reference/auth/config#site_url). You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings).
+
+You can use wildcard match patterns to support preview URLs from providers like Netlify and Vercel.
+
+A full list of supported pattern syntax can be found [here](https://pkg.go.dev/github.com/gobwas/glob#Compile).
+
+#### Netlify preview URLs
+
+For deployments with Netlify, set the `SITE_URL` to your official site URL. Add the following additional redirect URLs for local development and deployment previews:
+
+- `http://localhost:3000/*/*`
+- `https://**--my_org.netlify.app/*`
+
+#### Vercel preview URLs
+
+For deployments with Vercel, set the `SITE_URL` to your official site URL. Add the following additional redirect URLs for local development and deployment previews:
+
+- `http://localhost:3000/*/*`
+- `https://**vercel.app/*/*`
+
+Vercel provides an environment variable for the URL of the deployment called `NEXT_PUBLIC_VERCEL_URL`. See the [Vercel docs](https://vercel.com/docs/concepts/projects/environment-variables#system-environment-variables) for more details. You can use this variable to dynamically redirect depending on the environment:
+
+```js
+const { data, error } = await supabase.auth.signInWithOAuth({
+ provider: 'github'
+ options: {
+ redirectTo: `${
+ process.env.NEXT_PUBLIC_VERCEL_URL
+ ? 'https://' + process.env.NEXT_PUBLIC_VERCEL_URL
+ : 'http://localhost:3000'
+ }`
+ }
+}
+```
+
## Authorization
When you need granular authorization rules, nothing beats PostgreSQL's Row Level Security (RLS).
diff --git a/apps/docs/docs/guides/auth/server-side-rendering.mdx b/apps/docs/docs/guides/auth/server-side-rendering.mdx
index c80ff1ce825..102ff4fbe78 100644
--- a/apps/docs/docs/guides/auth/server-side-rendering.mdx
+++ b/apps/docs/docs/guides/auth/server-side-rendering.mdx
@@ -48,7 +48,7 @@ server redirects the user back to your single-page app.
<Admonition type="tip">
-You can configure [redirects URLs](https://app.supabase.com/project/_/auth/url-configuration) in the Supabase Dashboard. You can use wildcard match patterns
+You can configure [redirects URLs](https://app.supabase.com/project/_/auth/url-configuration) in the Supabase Dashboard. You can use [wildcard match patterns](/docs/guides/auth#redirect-urls-and-wildcards)
like `*` and `**` to allow redirects to different forms of URLs.
</Admonition>
diff --git a/spec/supabase_js_v2.yml b/spec/supabase_js_v2.yml
index c3ee9260119..9df7075f297 100644
--- a/spec/supabase_js_v2.yml
+++ b/spec/supabase_js_v2.yml
@@ -214,8 +214,8 @@ pages:
- name: Sign in using a third-party provider with redirect
isSpotlight: false
description: |
- When the third-party provider successfully authenticates the user, the provider will redirect the user to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url). It does not redirect the user immediately after invoking this method.
- You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings).
+ When the third-party provider successfully authenticates the user, the provider will redirect the user to the Supabase Auth callback URL from where they will be further redirected to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url).
+ You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings). You can use [wildcard match patterns](/docs/guides/auth#redirect-urls-and-wildcards) to support preview URLs from providers like Netlify and Vercel.
js: |
```js
const { data, error } = await supabase.auth.signInWithOAuth({
diff --git a/spec/supabase_js_v2_temp.yml b/spec/supabase_js_v2_temp.yml
index 0a42193dfd8..79b40bfc863 100644
--- a/spec/supabase_js_v2_temp.yml
+++ b/spec/supabase_js_v2_temp.yml
@@ -214,8 +214,8 @@ pages:
- name: Sign in using a third-party provider with redirect
isSpotlight: false
description: |
- When the third-party provider successfully authenticates the user, the provider will redirect the user to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url). It does not redirect the user immediately after invoking this method.
- You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings).
+ When the third-party provider successfully authenticates the user, the provider will redirect the user to the Supabase Auth callback URL from where they will be further redirected to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url).
+ You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings). You can use [wildcard match patterns](/docs/guides/auth#redirect-urls-and-wildcards) to support preview URLs from providers like Netlify and Vercel.
js: |
```js
const { data, error } = await supabase.auth.signInWithOAuth({