POSTGRES_URI is required during build time when using with next-auth/beta ?
Unanswered
hazamashoken posted this in #help-forum
So I have this simple google auth build with next-auth + drizzle orm pg adapter.
for testing purposes, currently there's only /api/auth/[...nextauth]/route.ts and auth.js for simple authentication
This cause
Even though it can be change again during run-time, it just very annoying to have to inject this variable in during build process.
Anyone have any solution or workaround that does not require setting
thank you.
for testing purposes, currently there's only /api/auth/[...nextauth]/route.ts and auth.js for simple authentication
This cause
ERR_INVALID_URL that came from DrizzleAdapterto be thrown during npm run buildEven though it can be change again during run-time, it just very annoying to have to inject this variable in during build process.
Anyone have any solution or workaround that does not require setting
POSTGRES_URI during build-time and changing it again ?thank you.
// route.ts
export { GET, POST } from "@/auth";// auth.js
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import { db } from "@/lib/db/clients";
import NextAuth from "next-auth";
import Google from "next-auth/providers/google";
export const {
handlers: { GET, POST },
auth,
} = NextAuth({
adapter: DrizzleAdapter(db),
session: {
strategy: "database",
},
providers: [Google],
});// package.json
{
"name": "app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@auth/drizzle-adapter": "^0.8.2",
"@radix-ui/react-slot": "^1.0.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"drizzle-orm": "^0.30.7",
"lucide-react": "^0.364.0",
"next": "14.1.4",
"next-auth": "^5.0.0-beta.16",
"pg": "^8.11.5",
"postgres": "^3.4.4",
"react": "^18",
"react-dom": "^18",
"tailwind-merge": "^2.2.2",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"drizzle-kit": "^0.20.14",
"eslint": "^8",
"eslint-config-next": "14.1.4",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
}3 Replies
Sun bear
is your env file named exactly as ".env"? I had problems with that as well.
Yes. My workaround is to have any valid but not the actual uri inject during build time then change it to the correct one o run time
bump