I got this error, althought I fill the env.local file with the data, I use nextjs
I wonder what's the issue is? I read that next js automatically handle env variables

.env.local file should be in your project root directory. If it's in a different location, Next.js might not be able to find it..env and .env.local, the values in .env.local will override the defaults.NEXT_PUBLIC_.process.env (start).env.$(NODE_ENV).local (where NODE_ENV can be any of development, production or test).env.local.env.$(NODE_ENV) (where NODE_ENV can be any of development, production or test).env (end).env.development.local and then redefine it in env.development, the value in env.development.local will be used.process.env.YOUR_VARIABLE_NAME.
string | undefined to be assigned to a variable of type string. process.env.SUPABASE_URL and process.env.SUPABASE_KEY are potentially undefined because environment variables in Node.js are undefined if they are not set. undefined. Here's how you can do it:process.env.SUPABASE_URL or process.env.SUPABASE_KEY is undefined, an empty string will be used as a default value. This ensures that SUPABASE_URL and SUPABASE_KEY are always strings, which satisfies TypeScript's type system..env.local file or in your hosting environment..env.local file is not in the root directory of your project..env.local file are not named correctly. They should match exactly with the ones you're trying to access in your code.NEXT_PUBLIC_. So if you want to use SUPABASE_URL in the browser, you should rename it to NEXT_PUBLIC_SUPABASE_URL.process.env.YOUR_VARIABLE_NAME.Error: supabaseKey is required indicates that the Supabase key is not being provided when creating the Supabase client. This could be due to the environment variable SUPABASE_KEY not being set correctly or not being accessible where it's being used.SUPABASE_KEY is correctly set in your .env.local file and that the file is located in the root directory of your project.SUPABASE_KEY on the client side, you need to prefix it with NEXT_PUBLIC_ in your .env.local file. So, it should be NEXT_PUBLIC_SUPABASE_KEY..env.local file. Environment variables are loaded when the server starts, so any changes won't take effect until the server is restarted.process.env to see all the environment variables that are currently set and check if SUPABASE_KEY or NEXT_PUBLIC_SUPABASE_KEY is among them.undefined, an empty string will be used as a default value. However, this will likely result in a different error because the Supabase client won't be able to connect to your Supabase instance without the correct URL and key.console.log(process.env) is returning an empty object, it means that your environment variables are not being loaded correctly. Here are a few things you can check:.env.local file is in the root directory of your project..env.local file are correctly named and formatted. They should be in the format VARIABLE_NAME=value, one per line.NEXT_PUBLIC_..env.local file. Environment variables are loaded when the server starts, so any changes won't take effect until the server is restarted..env.local file is in the root directory and you've followed the correct format for defining environment variables, but you're still unable to access them, it could be due to how your project is configured or how you're trying to access the variables.dotenv, you need to configure it at the top of your file before any other code.NEXT_PUBLIC_.next.config.js for Next.js projects) to make sure they're not interfering with how environment variables are loaded..env.local file is not ignored. Next.js ignores .env.local during the build step when it's inside .gitignore.dotenv is working correctly, you need to configure it at the top of your main server file (like server.js or index.js) before any other code. Here's how you can do it:.env file into process.env.process.env.YOUR_VARIABLE_NAME in your code.dotenv package in your project using npm or yarn:.env file is in the root directory of your project and it's not included in your .gitignore file. The .env file should not be committed to version control as it often contains sensitive information..env.local during both development and production builds, so you don't need to use dotenv in a Next.js project..env.local file in the root of your project.VARIABLE_NAME=value, one per line.process.env.VARIABLE_NAME.NEXT_PUBLIC_..env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.local.env.localNEXT_PUBLIC_NEXT_PUBLIC_NEXT_PUBLIC_NEXT_PUBLIC_NEXT_PUBLIC_NEXT_PUBLIC_.env.$(NODE_ENV).localNODE_ENVNODE_ENVdevelopmentdevelopment.env.$(NODE_ENV).env.development.localenv.developmentenv.development.localprocess.env.YOUR_VARIABLE_NAMEprocess.env.YOUR_VARIABLE_NAMEprocess.env.YOUR_VARIABLE_NAMEArgument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.ts(2345)const SUPABASE_URL = process.env.SUPABASE_URL as string;
const SUPABASE_KEY = process.env.SUPABASE_KEY as string;string | undefinedprocess.env.SUPABASE_URLprocess.env.SUPABASE_URLprocess.env.SUPABASE_KEYprocess.env.SUPABASE_KEYSUPABASE_URLSUPABASE_URLSUPABASE_KEYSUPABASE_KEYSUPABASE_KEYSUPABASE_KEYSUPABASE_KEYNEXT_PUBLIC_SUPABASE_URL⨯ node_modules\@supabase\supabase-js\dist\module\SupabaseClient.js (43:18) @ new SupabaseClient
⨯ Error: supabaseKey is required.
at eval (./src/utility/supabase-client.ts:9:89)
at (ssr)/./src/utility/supabase-client.ts (C:\Users\user\Documents\Dev\lms-pondokit-be\.next\server\app\login\page.js:359:1)
at __webpack_require__ (C:\Users\user\Documents\Dev\lms-pondokit-be\.next\server\webpack-runtime.js:33:42)
at eval (./src/providers/auth-provider/auth-provider.ts:5:82)
at (ssr)/./src/providers/auth-provider/auth-provider.ts (C:\Users\user\Documents\Dev\lms-pondokit-be\.next\server\app\login\page.js:326:1)
at __webpack_require__ (C:\Users\user\Documents\Dev\lms-pondokit-be\.next\server\webpack-runtime.js:33:42)
at JSON.parse (<anonymous>)
nullError: supabaseKey is requiredNEXT_PUBLIC_SUPABASE_KEYNEXT_PUBLIC_SUPABASE_KEYconsole.log(process.env);VARIABLE_NAME=valueVARIABLE_NAME=valuedotenvdotenvdotenvdotenvprocess.env.VARIABLE_NAMEconst SUPABASE_URL = process.env.SUPABASE_URL ?? "";
const SUPABASE_KEY = process.env.SUPABASE_KEY ?? "";import { createClient } from "@supabase/supabase-js";
const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL ?? "";
const SUPABASE_KEY = process.env.NEXT_PUBLIC_SUPABASE_KEY ?? "";
export const supabaseClient = createClient(SUPABASE_URL, SUPABASE_KEY);require('dotenv').config();import dotenv from 'dotenv';
dotenv.config();npm install dotenvyarn add dotenv