1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

supabase.jsでsupabaseUrlを受け取れず、chrome devツールに「Error: supabaseUrl is required.」が出ている

Posted at

はじめに

supabaseからのデータを、subapase-clientを利用して使用しようとしたが、うまくいかなかった

問題

supabase.jsでsupabaseUrlを受け取れず、developerツールに以下エラーが出ている。

  • src/utils/supabase.js
import { createClient } from "@supabase/supabase-js";

console.log("import.meta.env", import.meta.env);

const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
const supabaseKey = import.meta.env.VITE_SUPABASE_ANON_KEY;

console.log("supabaseUrl", supabaseUrl);
console.log("supabaseKey", supabaseKey);

const supabase = createClient(supabaseUrl, supabaseKey);

export default supabase;
Error: supabaseUrl is required.

image.png

解決方法

.envのディレクトリを間違えていた。
src/.envとなっていたが、.envとプロジェクトのルートに置くべきだった。

誤り(src/.envになっている)
image.png

おわりに

かなり時間がかかってしまいました。
.envのディレクトリにも気をつけるようにします。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?