英文:
Can't deploy react with typescript, vite and supabase in netlify
问题 {#heading}
在我的本地开发环境中没有问题,但我无法使用Netlify部署它,它抛出一个错误:
Uncaught Error: supabaseUrl is required.
我的supabaseConfig文件:
import { createClient } from '@supabase/supabase-js'
const supabaseKey = import.meta.env.VITE_SUPABASE_API_KEY;
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
const supabase = createClient(supabaseUrl, supabaseKey)
export default supabase
这是我的.env变量:
VITE_SUPABASE_API_KEY="mySupabaseApiKey"
VITE_SUPABASE_URL="mySupabaseUrl"
我的.env文件位于根目录下,我还安装了dotenv包,我搜索了但仍然无法解决这个问题。 英文:
No problem in my local development but i cant deploy it using netlify and it throws an error:
Uncaught Error: supabaseUrl is required.
My supabaseConfig file:
import { createClient } from '@supabase/supabase-js'
const supabaseKey = import.meta.env.VITE_SUPABASE_API_KEY;
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
const supabase = createClient(supabaseUrl, supabaseKey)
export default supabase
Here's my .env variables:
VITE_SUPABASE_API_KEY="mySupabaseApiKey"
VITE_SUPABASE_URL="mySupabaseUrl"
My .env is in the root directory, i also installed the dotenv package, i searched but still cant resolve this issue.
答案1 {#1}
得分: 0
你需要将你的环境变量添加到Netlify仪表板才能使其工作。你可以从Netlify文档网站 https://docs.netlify.com/environment-variables/overview/ 阅读更多关于如何做到这一点的信息。 英文:
You need to add your environment variables to the Netlify dashboard for this to work. You can read more about how to do this from the Netlify documentation website https://docs.netlify.com/environment-variables/overview/