supabaseUrl or supabaseKey required #3218
-
SupabaseClient.ts: These two errors I'm getting in my React project (one at a time, not both together) are rather frustrating since my supabaseUrl and supabaseKey are, and have always been, provided to the I updated Casey |
Beta Was this translation helpful? Give feedback.
Replies: 20 comments 66 replies
-
Hi @CaseyG5! I am sorry that you are having some trouble. I just upgraded one of my Next.js project to use both v1.22.5 and v1.22.6 of Could you share your code where you are calling |
Beta Was this translation helpful? Give feedback.
-
Is it possible there’s a trailing slash in the URL? |
Beta Was this translation helpful? Give feedback.
-
having the same issue |
Beta Was this translation helpful? Give feedback.
-
Hello just wanted to chime in here. I had this same problem and realized my mistake was that I accidentally put my .env.local file in my src folder instead of project route. Just in case anyone is having this issue. |
Beta Was this translation helpful? Give feedback.
-
Hello.
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL as string
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY as string
export const supabase = createClient(supabaseUrl, supabaseAnonKey) |
Beta Was this translation helpful? Give feedback.
-
i faced the same thing after deploying, but in my case i was using |
Beta Was this translation helpful? Give feedback.
-
Hello, IDK why but just add prefix
to
BlackCAT |
Beta Was this translation helpful? Give feedback.
-
Btw - if anyone is working with Vercel, make sure to add your environment variables to the Vercel dashboard! Spent so much time trying to fix it locally... |
Beta Was this translation helpful? Give feedback.
-
If you're using Vercel you might've set environmental variables only for |
Beta Was this translation helpful? Give feedback.
-
I was facing the same issue, in one Good code to everyone! |
Beta Was this translation helpful? Give feedback.
-
Tenia el mismo problema, use vercel para el deploy, solo tuve que colocar en la configuracion del proyecto las variables de entorno del proyecto y se quita el error I had the same problem, I used vercel for the deploy, I only had to put in the project configuration the project environment variables and the error is removed. |
Beta Was this translation helpful? Give feedback.
-
Hello there 👋🏻 I have encountered the same issue and resolved it by wrapping the 🚨 Whenever you do changes in the |
Beta Was this translation helpful? Give feedback.
-
When I build with next.js13.4.2, I get "Error: supabaseUrl is required." However, in the local environment, such an error does not occur and it works properly. Has anyone had a similar issue and resolved it? (.env.local) (supabase.ts) |
Beta Was this translation helpful? Give feedback.
-
in my case the error was |
Beta Was this translation helpful? Give feedback.
-
just create a project in supabase and you will get the anon key ad url,put them in the create client |
Beta Was this translation helpful? Give feedback.
-
remove the " " from your environment variables.
…On Sun, Dec 10, 2023 at 10:00 AM Piyush ***@***.***> wrote:
I am creating a spotify clone app for personal project and i am facing
this error can anyone please help me out with what is wrong going on with
the code? This is the error I'm facing.
⨯ ***@***.***\auth-helpers-nextjs\dist\index.js (47:10) @
createClientComponentClient
⨯ Error: either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY
env variables or supabaseUrl and supabaseKey are required!
at eval (./providers/SupabaseProvider.tsx:18:172)
at SupabaseProvider (./providers/SupabaseProvider.tsx:18:77)
null
Screenshot.36.png (view on web)
<https://github.com/supabase/supabase/assets/87450143/d89b7a00-f946-4685-9d90-765270fa051e>
Screenshot.37.png (view on web)
<https://github.com/supabase/supabase/assets/87450143/d7020888-e7dc-4234-bc73-4c1cce98857c>
Screenshot.38.png (view on web)
<https://github.com/supabase/supabase/assets/87450143/0c6f89a7-5c69-4fb2-aeeb-995c001d7957>
—
Reply to this email directly, view it on GitHub
<#3218 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BAF733STUXK4VTO2V2CG5V3YIVMXJAVCNFSM5ECZ3FW2U5DIOJSWCZC7NNSXTOKENFZWG5LTONUW63SDN5WW2ZLOOQ5TOOBRGAZTGMQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Is it safe to expose the Supabase keys? Because NEXT_PUBLIC expose the keys in public, I think their docs are not that good in terms of security. |
Beta Was this translation helpful? Give feedback.
-
this problem happened to me although i was correctly named the environment variable file(.env.local) and also correctly named the variables in this file correctly so when i fixed this , this works well and that error disappeared |
Beta Was this translation helpful? Give feedback.
-
Very helpful comments here. Thanks for the contributions. I have got similar error and finally managed to resolved it. Here are my settings. I am using Next.js framework. Created .env file. This is placed under the root of your project. NEXT_PUBLIC_SUPABASE_URL=https://yourdb.supabase.co Next I have created a directory called lib
import { createClient } from "@supabase/supabase-js"; export const supabase = createClient( export const supabaseAdmin = createClient(
import { createClient } from '@supabase/supabase-js' const supabaseUrl = process.env.PUBLIC_SUPABASE_URL as string; console.log("Supabase URL:", supabaseUrl); // Check if this prints the correct value if (!supabaseUrl || !supabaseAnonKey) { const supabase = createClient(supabaseUrl, supabaseAnonKey); export default supabase;
import { createClient } from '@supabase/supabase-js' const supabaseUrl = process.env.PUBLIC_SUPABASE_URL as string; console.log("Supabase URL:", supabaseUrl); // Check if this prints the correct value if (!supabaseUrl || !supabaseServiceRoleKey) { export const supabase = createClient(supabaseUrl, supabaseServiceRoleKey); So all the above three files are placed under the lib directory. Finally under the the page where you want to insert const insertNewUser = async () => {
} insertNewUser(); Create auth policies for your table. Thanks |
Beta Was this translation helpful? Give feedback.
-
This doesn't resolve issue that key is unsafe even with row level security someone can still upload or access images |
Beta Was this translation helpful? Give feedback.
Hi @CaseyG5!
I am sorry that you are having some trouble. I just upgraded one of my Next.js project to use both v1.22.5 and v1.22.6 of
supabase-js
, and was not able to reproduce this issue with both annon key and service key. Do you know if this issue happened on earlier versions ofsupabase-js
?Could you share your code where you are calling
createClient()
?