saasykits / next-lucia-auth

This is a Next.js T3 project with authentication implemented using Lucia.
https://next-lucia.vercel.app
MIT License
471 stars 59 forks source link

Documentation: Hosting locally. #40

Open Fr3akyMurk opened 7 months ago

Fr3akyMurk commented 7 months ago

Greetings. As you may already know, i have been battling with drizzle, mysql and planetscale, where most of the issues came from SSL errors.

I have found my solution to my problem. I found out that planetscale uses HTTP / HTTPS to connect to instances, something planetscale supports but not something standard mysql servers do.

so this is my new index.ts file in drizzle that works.

import { drizzle } from "drizzle-orm/mysql2";
import mysql from 'mysql2';

// Create a MySQL connection pool (synchronous operation)

/*
Some options include:
    host: process.env["DATABASE_HOST"],
    user: process.env["DATABASE_USERNAME"],
    password: process.env["DATABASE_PASSWORD"],
    database: process.env["DATABASE_NAME"],
*/

import { env } from "@/env";
import * as schema from "./schema";

const pool = mysql.createPool({
    uri: 'mysql://root:MARIADB@localhost:3306/lucia',
    waitForConnections: true,
    connectionLimit: 10,
    queueLimit: 0
});

export const db = drizzle(pool, { schema, mode: "default" });

I do not care about the connection URI, it's local.

Fr3akyMurk commented 7 months ago

@iamtouha Resolves issue #26