最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Supabase Db Query is super slow with simple test query using service role - Stack Overflow

programmeradmin3浏览0评论

A Simple db query in a table with just 2 rows takes atleast 12 seconds, sometimes timeout! What is the mistake in my code? My code works so credentials are correct. I don't use Supabase auth, so I use the service role only to fetch data in the backend.

import { createClient } from "@supabase/supabase-js";
import { NextRequest, NextResponse } from "next/server";

const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!;
const serviceRoleKey = process.env.SUPABASE_SERVICE_ROLE_KEY!;
const supabase = createClient(supabaseUrl, serviceRoleKey);

export async function GET(req: NextRequest) {
  try {
    const { data, error } = await supabase.from("formdata").select("*");

    if (error) {
      throw error;
    }

    return NextResponse.json({ how: "Using client, serviceRoleKey", data });
  } catch (err: any) {
    return NextResponse.json({ error: err.message }, { status: 500 });
  }
}
发布评论

评论列表(0)

  1. 暂无评论