tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
9.54k stars 252 forks source link

LibsqlError: SERVER_ERROR: Server returned HTTP status 401 #1738

Closed DaliborPan closed 1 week ago

DaliborPan commented 1 week ago

I have a Next.js application using Drizzle ORM and a Turso database. While I can easily connect to the Turso database from localhost, when deployed on Vercel, I encounter the error: LibsqlError: SERVER_ERROR: Server returned HTTP status 401.

I’ve tried everything to fix this: recreating the database, regenerating the auth token, and even hardcoding the database URL and auth token directly into the code (bypassing the use of environment variables). Nothing has worked.

// app/login/page.tsx

import { db } from '@/db';

const Page = async () => {
    const users = await db.query.users.findMany();

    console.log('USERS: ', users);

    return ...
}

export default Page;
image
ericvalcik commented 1 week ago

Ran into the same issue too, locally everything works but on Vercel I'm getting the same error.

DaliborPan commented 1 week ago

Updating @libsql/client: to 0.12.0 solved my issue.

DevHustler4 commented 1 week ago

Thanks 🙏, I also get the same error,