nicoalbanese / kirimase

Build full-stack Next.js apps, incredibly fast
https://kirimase.dev
MIT License
2.39k stars 107 forks source link

Fresh init with NextAuth (google) immediately errors (solution provided) #125

Closed KenzoBenzo closed 5 months ago

KenzoBenzo commented 5 months ago

Config File

  "hasSrc": false,
  "packages": [
    "shadcn-ui",
    "drizzle",
    "next-auth"
  ],
  "preferredPackageManager": "pnpm",
  "t3": false,
  "alias": "@",
  "rootPath": "",
  "componentLib": "shadcn-ui",
  "driver": "pg",
  "provider": "neon",
  "orm": "drizzle",
  "auth": "next-auth"
}

Describe the bug When initializing with NextAuth and Google, the provider is not added in correctly.

Expected behavior On initialization, after adding environment variables

Additional context A couple of things fix this. Starting with, in the file utils.ts:

We need to add these two imports

import GoogleProvider from "next-auth/providers/google";
import { env } from "@/lib/env.mjs";

Inside of the array of providers this code needs to be added (if google is selected)

GoogleProvider({
  clientId: env.GOOGLE_CLIENT_ID,
  clientSecret: env.GOOGLE_CLIENT_SECRET,
}),

Then in the file env.mjs: Two new environment variable checks need to be made

GOOGLE_CLIENT_ID: z.string().min(1),
GOOGLE_CLIENT_SECRET: z.string().min(1),

Then finally the default .env file needs to contain two more placeholders

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
nicoalbanese commented 5 months ago

Hey @KenzoBenzo! sorry you're experiencing this and thanks for flagging 😊

I've just tried to recreate with 0.0.47 and haven't been able to (I have intended behaviour you describe above). Just double checking that you toggled google provider with spacebar? Sorry if that comes across as patronizing! Just want to make sure. If so, can you try to force-clean the cache of your package manager or try a new one?

https://github.com/nicoalbanese/kirimase/assets/49612682/6a0f3bb4-7597-4e10-8eb1-5b156d5dcc49

KenzoBenzo commented 5 months ago

Hey @nicoalbanese — thanks for responding so quickly!

I am using v0.0.46 for reference and potentially did slip without selecting since I'm not seeing the same behavior on a fresh try. Potentially worth making it a required step? Or output info if you didn't select an option before moving on? Certainly not high priority though, will close since it seems like a non-issue.

nicoalbanese commented 5 months ago

No problem! happy to hear it's sorted. So it was an intentional decision to not force anyone into one of the four providers but I like your idea to add a confirmation step (like if you don't select an orm). Will add to the list! Thanks 😊