From b5ca0c63632cb3699b26f077a1952caf3ac267c3 Mon Sep 17 00:00:00 2001 From: Matvey Ryabchikov <35634442+ronanru@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:02:54 +0300 Subject: [PATCH 01/16] feat: update to next 15 --- cli/src/helpers/createProject.ts | 4 ++-- cli/src/installers/envVars.ts | 4 ++-- .../base/{next.config.js => next.config.ts} | 13 ++++--------- cli/template/base/package.json | 2 +- cli/template/base/src/{env.js => env.ts} | 0 ...{next-config-appdir.js => next-config-appdir.ts} | 7 ++++--- cli/template/extras/src/trpc/server.ts | 4 ++-- 7 files changed, 15 insertions(+), 19 deletions(-) rename cli/template/base/{next.config.js => next.config.ts} (55%) rename cli/template/base/src/{env.js => env.ts} (100%) rename cli/template/extras/config/{next-config-appdir.js => next-config-appdir.ts} (60%) diff --git a/cli/src/helpers/createProject.ts b/cli/src/helpers/createProject.ts index 81b385485f..92aa6ed49e 100644 --- a/cli/src/helpers/createProject.ts +++ b/cli/src/helpers/createProject.ts @@ -64,8 +64,8 @@ export const createProject = async ({ if (appRouter) { // Replace next.config fs.copyFileSync( - path.join(PKG_ROOT, "template/extras/config/next-config-appdir.js"), - path.join(projectDir, "next.config.js") + path.join(PKG_ROOT, "template/extras/config/next-config-appdir.ts"), + path.join(projectDir, "next.config.ts") ); selectLayoutFile({ projectDir, packages }); diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index a7377ccf6e..281ea7e331 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -44,7 +44,7 @@ export const envVariablesInstaller: Installer = ({ "template/extras/src/env", envFile ); - const envSchemaDest = path.join(projectDir, "src/env.js"); + const envSchemaDest = path.join(projectDir, "src/env.ts"); fs.copyFileSync(envSchemaSrc, envSchemaDest); } @@ -63,7 +63,7 @@ const getEnvContent = ( scopedAppName: string ) => { let content = ` -# When adding additional environment variables, the schema in "/src/env.js" +# When adding additional environment variables, the schema in "/src/env.ts" # should be updated accordingly. ` .trim() diff --git a/cli/template/base/next.config.js b/cli/template/base/next.config.ts similarity index 55% rename from cli/template/base/next.config.js rename to cli/template/base/next.config.ts index 98b6f90a51..a3c840a8ca 100644 --- a/cli/template/base/next.config.js +++ b/cli/template/base/next.config.ts @@ -1,23 +1,18 @@ +import { type NextConfig } from "next"; + /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful * for Docker builds. */ -await import("./src/env.js"); +import "./src/env"; -/** @type {import("next").NextConfig} */ const config = { reactStrictMode: true, - - /** - * If you are using `appDir` then you must comment the below `i18n` config out. - * - * @see https://github.com/vercel/next.js/issues/41980 - */ i18n: { locales: ["en"], defaultLocale: "en", }, transpilePackages: ["geist"], -}; +} satisfies NextConfig; export default config; diff --git a/cli/template/base/package.json b/cli/template/base/package.json index fff75519f8..85dab873ef 100644 --- a/cli/template/base/package.json +++ b/cli/template/base/package.json @@ -16,7 +16,7 @@ "dependencies": { "@t3-oss/env-nextjs": "^0.10.1", "geist": "^1.3.0", - "next": "^14.2.4", + "next": "^15.0.0", "react": "^18.3.1", "react-dom": "^18.3.1", "zod": "^3.23.3" diff --git a/cli/template/base/src/env.js b/cli/template/base/src/env.ts similarity index 100% rename from cli/template/base/src/env.js rename to cli/template/base/src/env.ts diff --git a/cli/template/extras/config/next-config-appdir.js b/cli/template/extras/config/next-config-appdir.ts similarity index 60% rename from cli/template/extras/config/next-config-appdir.js rename to cli/template/extras/config/next-config-appdir.ts index 9bfe4a0e2a..812e25a83f 100644 --- a/cli/template/extras/config/next-config-appdir.js +++ b/cli/template/extras/config/next-config-appdir.ts @@ -1,10 +1,11 @@ +import { type NextConfig } from "next"; + /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful * for Docker builds. */ -await import("./src/env.js"); +import "./src/env"; -/** @type {import("next").NextConfig} */ -const config = {}; +const config = {} satisfies NextConfig; export default config; diff --git a/cli/template/extras/src/trpc/server.ts b/cli/template/extras/src/trpc/server.ts index 59300a638b..91e557e45f 100644 --- a/cli/template/extras/src/trpc/server.ts +++ b/cli/template/extras/src/trpc/server.ts @@ -12,8 +12,8 @@ import { createQueryClient } from "./query-client"; * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when * handling a tRPC call from a React Server Component. */ -const createContext = cache(() => { - const heads = new Headers(headers()); +const createContext = cache(async () => { + const heads = new Headers(await headers()); heads.set("x-trpc-source", "rsc"); return createTRPCContext({ From 905e907ae42a2e5c3be2baae69a526958379f70c Mon Sep 17 00:00:00 2001 From: Matvey Ryabchikov <35634442+ronanru@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:49:17 +0300 Subject: [PATCH 02/16] feat: use next-auth v5 (v4 doesn't supports next 15) --- cli/src/installers/dependencyVersionMap.ts | 2 +- cli/src/installers/nextAuth.ts | 17 ++-- .../src/app/api/auth/[...nextauth]/route.ts | 8 +- .../extras/src/app/page/with-auth-trpc-tw.tsx | 4 +- .../extras/src/app/page/with-auth-trpc.tsx | 4 +- .../src/pages/api/auth/[...nextauth].ts | 5 -- .../src/server/api/trpc-app/with-auth-db.ts | 4 +- .../src/server/api/trpc-app/with-auth.ts | 4 +- .../src/server/api/trpc-pages/with-auth-db.ts | 4 +- .../src/server/api/trpc-pages/with-auth.ts | 4 +- .../extras/src/server/auth-pages/base.ts | 74 --------------- .../src/server/auth-pages/with-drizzle.ts | 89 ------------------- .../src/server/auth-pages/with-prisma.ts | 78 ---------------- .../src/server/{auth-app => auth}/base.ts | 42 +++------ .../server/{auth-app => auth}/with-drizzle.ts | 51 ++++------- .../server/{auth-app => auth}/with-prisma.ts | 41 +++------ 16 files changed, 56 insertions(+), 375 deletions(-) delete mode 100644 cli/template/extras/src/pages/api/auth/[...nextauth].ts delete mode 100644 cli/template/extras/src/server/auth-pages/base.ts delete mode 100644 cli/template/extras/src/server/auth-pages/with-drizzle.ts delete mode 100644 cli/template/extras/src/server/auth-pages/with-prisma.ts rename cli/template/extras/src/server/{auth-app => auth}/base.ts (53%) rename cli/template/extras/src/server/{auth-app => auth}/with-drizzle.ts (61%) rename cli/template/extras/src/server/{auth-app => auth}/with-prisma.ts (56%) diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index 062c9e3740..66f957c40f 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -4,7 +4,7 @@ */ export const dependencyVersionMap = { // NextAuth.js - "next-auth": "^4.24.7", + "next-auth": "beta", "@auth/prisma-adapter": "^1.6.0", "@auth/drizzle-adapter": "^1.1.0", diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index 0886e90d7e..a3afcc1977 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -6,11 +6,7 @@ import { type AvailableDependencies } from "~/installers/dependencyVersionMap.js import { type Installer } from "~/installers/index.js"; import { addPackageDependency } from "~/utils/addPackageDependency.js"; -export const nextAuthInstaller: Installer = ({ - projectDir, - packages, - appRouter, -}) => { +export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const usingPrisma = packages?.prisma.inUse; const usingDrizzle = packages?.drizzle.inUse; @@ -26,17 +22,14 @@ export const nextAuthInstaller: Installer = ({ const extrasDir = path.join(PKG_ROOT, "template/extras"); - const apiHandlerFile = "src/pages/api/auth/[...nextauth].ts"; - const routeHandlerFile = "src/app/api/auth/[...nextauth]/route.ts"; - const srcToUse = appRouter ? routeHandlerFile : apiHandlerFile; + const apiHandlerFile = "src/app/api/auth/[...nextauth]/route.ts"; - const apiHandlerSrc = path.join(extrasDir, srcToUse); - const apiHandlerDest = path.join(projectDir, srcToUse); + const apiHandlerSrc = path.join(extrasDir, apiHandlerFile); + const apiHandlerDest = path.join(projectDir, apiHandlerFile); const authConfigSrc = path.join( extrasDir, - "src/server", - appRouter ? "auth-app" : "auth-pages", + "src/server/auth", usingPrisma ? "with-prisma.ts" : usingDrizzle diff --git a/cli/template/extras/src/app/api/auth/[...nextauth]/route.ts b/cli/template/extras/src/app/api/auth/[...nextauth]/route.ts index 7ef89677f2..8e8302c8d8 100644 --- a/cli/template/extras/src/app/api/auth/[...nextauth]/route.ts +++ b/cli/template/extras/src/app/api/auth/[...nextauth]/route.ts @@ -1,7 +1,3 @@ -import NextAuth from "next-auth"; +import { handlers } from "~/server/auth"; -import { authOptions } from "~/server/auth"; - -// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -const handler = NextAuth(authOptions); -export { handler as GET, handler as POST }; +export const { GET, POST } = handlers; diff --git a/cli/template/extras/src/app/page/with-auth-trpc-tw.tsx b/cli/template/extras/src/app/page/with-auth-trpc-tw.tsx index 1d462b4441..37cc32ff48 100644 --- a/cli/template/extras/src/app/page/with-auth-trpc-tw.tsx +++ b/cli/template/extras/src/app/page/with-auth-trpc-tw.tsx @@ -1,12 +1,12 @@ import Link from "next/link"; import { LatestPost } from "~/app/_components/post"; -import { getServerAuthSession } from "~/server/auth"; +import { auth } from "~/server/auth"; import { api, HydrateClient } from "~/trpc/server"; export default async function Home() { const hello = await api.post.hello({ text: "from tRPC" }); - const session = await getServerAuthSession(); + const session = await auth(); if (session?.user) { void api.post.getLatest.prefetch(); diff --git a/cli/template/extras/src/app/page/with-auth-trpc.tsx b/cli/template/extras/src/app/page/with-auth-trpc.tsx index 74cac168f9..ba570d252e 100644 --- a/cli/template/extras/src/app/page/with-auth-trpc.tsx +++ b/cli/template/extras/src/app/page/with-auth-trpc.tsx @@ -1,13 +1,13 @@ import Link from "next/link"; import { LatestPost } from "~/app/_components/post"; -import { getServerAuthSession } from "~/server/auth"; +import { auth } from "~/server/auth"; import { api, HydrateClient } from "~/trpc/server"; import styles from "./index.module.css"; export default async function Home() { const hello = await api.post.hello({ text: "from tRPC" }); - const session = await getServerAuthSession(); + const session = await auth(); if (session?.user) { void api.post.getLatest.prefetch(); diff --git a/cli/template/extras/src/pages/api/auth/[...nextauth].ts b/cli/template/extras/src/pages/api/auth/[...nextauth].ts deleted file mode 100644 index 8739530ffd..0000000000 --- a/cli/template/extras/src/pages/api/auth/[...nextauth].ts +++ /dev/null @@ -1,5 +0,0 @@ -import NextAuth from "next-auth"; - -import { authOptions } from "~/server/auth"; - -export default NextAuth(authOptions); diff --git a/cli/template/extras/src/server/api/trpc-app/with-auth-db.ts b/cli/template/extras/src/server/api/trpc-app/with-auth-db.ts index 0021e07cbd..00d924faa8 100644 --- a/cli/template/extras/src/server/api/trpc-app/with-auth-db.ts +++ b/cli/template/extras/src/server/api/trpc-app/with-auth-db.ts @@ -11,7 +11,7 @@ import { initTRPC, TRPCError } from "@trpc/server"; import superjson from "superjson"; import { ZodError } from "zod"; -import { getServerAuthSession } from "~/server/auth"; +import { auth } from "~/server/auth"; import { db } from "~/server/db"; /** @@ -27,7 +27,7 @@ import { db } from "~/server/db"; * @see https://trpc.io/docs/server/context */ export const createTRPCContext = async (opts: { headers: Headers }) => { - const session = await getServerAuthSession(); + const session = await auth(); return { db, diff --git a/cli/template/extras/src/server/api/trpc-app/with-auth.ts b/cli/template/extras/src/server/api/trpc-app/with-auth.ts index 3c688d34c2..755b973c29 100644 --- a/cli/template/extras/src/server/api/trpc-app/with-auth.ts +++ b/cli/template/extras/src/server/api/trpc-app/with-auth.ts @@ -10,7 +10,7 @@ import { initTRPC, TRPCError } from "@trpc/server"; import superjson from "superjson"; import { ZodError } from "zod"; -import { getServerAuthSession } from "~/server/auth"; +import { auth } from "~/server/auth"; /** * 1. CONTEXT @@ -25,7 +25,7 @@ import { getServerAuthSession } from "~/server/auth"; * @see https://trpc.io/docs/server/context */ export const createTRPCContext = async (opts: { headers: Headers }) => { - const session = await getServerAuthSession(); + const session = await auth(); return { session, diff --git a/cli/template/extras/src/server/api/trpc-pages/with-auth-db.ts b/cli/template/extras/src/server/api/trpc-pages/with-auth-db.ts index b0456c8f94..8b4f3632a7 100644 --- a/cli/template/extras/src/server/api/trpc-pages/with-auth-db.ts +++ b/cli/template/extras/src/server/api/trpc-pages/with-auth-db.ts @@ -13,7 +13,7 @@ import { type Session } from "next-auth"; import superjson from "superjson"; import { ZodError } from "zod"; -import { getServerAuthSession } from "~/server/auth"; +import { auth } from "~/server/auth"; import { db } from "~/server/db"; /** @@ -55,7 +55,7 @@ export const createTRPCContext = async (opts: CreateNextContextOptions) => { const { req, res } = opts; // Get the session from the server using the getServerSession wrapper function - const session = await getServerAuthSession({ req, res }); + const session = await auth(req, res); return createInnerTRPCContext({ session, diff --git a/cli/template/extras/src/server/api/trpc-pages/with-auth.ts b/cli/template/extras/src/server/api/trpc-pages/with-auth.ts index 3148e056f1..7fe732be6b 100644 --- a/cli/template/extras/src/server/api/trpc-pages/with-auth.ts +++ b/cli/template/extras/src/server/api/trpc-pages/with-auth.ts @@ -12,7 +12,7 @@ import { type Session } from "next-auth"; import superjson from "superjson"; import { ZodError } from "zod"; -import { getServerAuthSession } from "~/server/auth"; +import { auth } from "~/server/auth"; /** * 1. CONTEXT @@ -53,7 +53,7 @@ export const createTRPCContext = async ({ res, }: CreateNextContextOptions) => { // Get the session from the server using the getServerSession wrapper function - const session = await getServerAuthSession({ req, res }); + const session = await auth(req, res); return createInnerTRPCContext({ session, diff --git a/cli/template/extras/src/server/auth-pages/base.ts b/cli/template/extras/src/server/auth-pages/base.ts deleted file mode 100644 index cbeceb4c16..0000000000 --- a/cli/template/extras/src/server/auth-pages/base.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { type GetServerSidePropsContext } from "next"; -import { - getServerSession, - type DefaultSession, - type NextAuthOptions, -} from "next-auth"; -import DiscordProvider from "next-auth/providers/discord"; - -import { env } from "~/env"; - -/** - * Module augmentation for `next-auth` types. Allows us to add custom properties to the `session` - * object and keep type safety. - * - * @see https://next-auth.js.org/getting-started/typescript#module-augmentation - */ -declare module "next-auth" { - interface Session extends DefaultSession { - user: DefaultSession["user"] & { - id: string; - // ...other properties - // role: UserRole; - }; - } - - // interface User { - // // ...other properties - // // role: UserRole; - // } -} - -/** - * Options for NextAuth.js used to configure adapters, providers, callbacks, etc. - * - * @see https://next-auth.js.org/configuration/options - */ -export const authOptions: NextAuthOptions = { - callbacks: { - session: ({ session, token }) => ({ - ...session, - user: { - ...session.user, - id: token.sub, - }, - }), - }, - providers: [ - DiscordProvider({ - clientId: env.DISCORD_CLIENT_ID, - clientSecret: env.DISCORD_CLIENT_SECRET, - }), - /** - * ...add more providers here. - * - * Most other providers require a bit more work than the Discord provider. For example, the - * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account - * model. Refer to the NextAuth.js docs for the provider you want to use. Example: - * - * @see https://next-auth.js.org/providers/github - */ - ], -}; - -/** - * Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file. - * - * @see https://next-auth.js.org/configuration/nextjs - */ -export const getServerAuthSession = (ctx: { - req: GetServerSidePropsContext["req"]; - res: GetServerSidePropsContext["res"]; -}) => { - return getServerSession(ctx.req, ctx.res, authOptions); -}; diff --git a/cli/template/extras/src/server/auth-pages/with-drizzle.ts b/cli/template/extras/src/server/auth-pages/with-drizzle.ts deleted file mode 100644 index c7788937f0..0000000000 --- a/cli/template/extras/src/server/auth-pages/with-drizzle.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { DrizzleAdapter } from "@auth/drizzle-adapter"; -import { type GetServerSidePropsContext } from "next"; -import { - getServerSession, - type DefaultSession, - type NextAuthOptions, -} from "next-auth"; -import { type Adapter } from "next-auth/adapters"; -import DiscordProvider from "next-auth/providers/discord"; - -import { env } from "~/env"; -import { db } from "~/server/db"; -import { - accounts, - sessions, - users, - verificationTokens, -} from "~/server/db/schema"; - -/** - * Module augmentation for `next-auth` types. Allows us to add custom properties to the `session` - * object and keep type safety. - * - * @see https://next-auth.js.org/getting-started/typescript#module-augmentation - */ -declare module "next-auth" { - interface Session extends DefaultSession { - user: { - id: string; - // ...other properties - // role: UserRole; - } & DefaultSession["user"]; - } - - // interface User { - // // ...other properties - // // role: UserRole; - // } -} - -/** - * Options for NextAuth.js used to configure adapters, providers, callbacks, etc. - * - * @see https://next-auth.js.org/configuration/options - */ -export const authOptions: NextAuthOptions = { - callbacks: { - session: ({ session, user }) => ({ - ...session, - user: { - ...session.user, - id: user.id, - }, - }), - }, - adapter: DrizzleAdapter(db, { - usersTable: users, - accountsTable: accounts, - sessionsTable: sessions, - verificationTokensTable: verificationTokens, - }) as Adapter, - providers: [ - DiscordProvider({ - clientId: env.DISCORD_CLIENT_ID, - clientSecret: env.DISCORD_CLIENT_SECRET, - }), - /** - * ...add more providers here. - * - * Most other providers require a bit more work than the Discord provider. For example, the - * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account - * model. Refer to the NextAuth.js docs for the provider you want to use. Example: - * - * @see https://next-auth.js.org/providers/github - */ - ], -}; - -/** - * Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file. - * - * @see https://next-auth.js.org/configuration/nextjs - */ -export const getServerAuthSession = (ctx: { - req: GetServerSidePropsContext["req"]; - res: GetServerSidePropsContext["res"]; -}) => { - return getServerSession(ctx.req, ctx.res, authOptions); -}; diff --git a/cli/template/extras/src/server/auth-pages/with-prisma.ts b/cli/template/extras/src/server/auth-pages/with-prisma.ts deleted file mode 100644 index ee03a40d73..0000000000 --- a/cli/template/extras/src/server/auth-pages/with-prisma.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { PrismaAdapter } from "@auth/prisma-adapter"; -import { type GetServerSidePropsContext } from "next"; -import { - getServerSession, - type DefaultSession, - type NextAuthOptions, -} from "next-auth"; -import { type Adapter } from "next-auth/adapters"; -import DiscordProvider from "next-auth/providers/discord"; - -import { env } from "~/env"; -import { db } from "~/server/db"; - -/** - * Module augmentation for `next-auth` types. Allows us to add custom properties to the `session` - * object and keep type safety. - * - * @see https://next-auth.js.org/getting-started/typescript#module-augmentation - */ -declare module "next-auth" { - interface Session extends DefaultSession { - user: DefaultSession["user"] & { - id: string; - // ...other properties - // role: UserRole; - }; - } - - // interface User { - // // ...other properties - // // role: UserRole; - // } -} - -/** - * Options for NextAuth.js used to configure adapters, providers, callbacks, etc. - * - * @see https://next-auth.js.org/configuration/options - */ -export const authOptions: NextAuthOptions = { - callbacks: { - session: ({ session, user }) => ({ - ...session, - user: { - ...session.user, - id: user.id, - }, - }), - }, - adapter: PrismaAdapter(db) as Adapter, - providers: [ - DiscordProvider({ - clientId: env.DISCORD_CLIENT_ID, - clientSecret: env.DISCORD_CLIENT_SECRET, - }), - /** - * ...add more providers here. - * - * Most other providers require a bit more work than the Discord provider. For example, the - * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account - * model. Refer to the NextAuth.js docs for the provider you want to use. Example: - * - * @see https://next-auth.js.org/providers/github - */ - ], -}; - -/** - * Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file. - * - * @see https://next-auth.js.org/configuration/nextjs - */ -export const getServerAuthSession = (ctx: { - req: GetServerSidePropsContext["req"]; - res: GetServerSidePropsContext["res"]; -}) => { - return getServerSession(ctx.req, ctx.res, authOptions); -}; diff --git a/cli/template/extras/src/server/auth-app/base.ts b/cli/template/extras/src/server/auth/base.ts similarity index 53% rename from cli/template/extras/src/server/auth-app/base.ts rename to cli/template/extras/src/server/auth/base.ts index 9c170aaaae..f64b28d47e 100644 --- a/cli/template/extras/src/server/auth-app/base.ts +++ b/cli/template/extras/src/server/auth/base.ts @@ -1,8 +1,4 @@ -import { - getServerSession, - type DefaultSession, - type NextAuthOptions, -} from "next-auth"; +import NextAuth, { type DefaultSession } from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env"; @@ -33,36 +29,20 @@ declare module "next-auth" { * * @see https://next-auth.js.org/configuration/options */ -export const authOptions: NextAuthOptions = { +export const { auth, handlers, signIn, signOut } = NextAuth({ + providers: [ + DiscordProvider({ + clientId: env.DISCORD_CLIENT_ID, + clientSecret: env.DISCORD_CLIENT_SECRET, + }), + ], callbacks: { - session: ({ session, token }) => ({ + session: ({ session, user }) => ({ ...session, user: { ...session.user, - id: token.sub, + id: user.id, }, }), }, - providers: [ - DiscordProvider({ - clientId: env.DISCORD_CLIENT_ID, - clientSecret: env.DISCORD_CLIENT_SECRET, - }), - /** - * ...add more providers here. - * - * Most other providers require a bit more work than the Discord provider. For example, the - * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account - * model. Refer to the NextAuth.js docs for the provider you want to use. Example: - * - * @see https://next-auth.js.org/providers/github - */ - ], -}; - -/** - * Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file. - * - * @see https://next-auth.js.org/configuration/nextjs - */ -export const getServerAuthSession = () => getServerSession(authOptions); +}); diff --git a/cli/template/extras/src/server/auth-app/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts similarity index 61% rename from cli/template/extras/src/server/auth-app/with-drizzle.ts rename to cli/template/extras/src/server/auth/with-drizzle.ts index 6e9281d157..81f31503ec 100644 --- a/cli/template/extras/src/server/auth-app/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -1,10 +1,5 @@ import { DrizzleAdapter } from "@auth/drizzle-adapter"; -import { - getServerSession, - type DefaultSession, - type NextAuthOptions, -} from "next-auth"; -import { type Adapter } from "next-auth/adapters"; +import NextAuth, { type DefaultSession } from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env"; @@ -42,7 +37,19 @@ declare module "next-auth" { * * @see https://next-auth.js.org/configuration/options */ -export const authOptions: NextAuthOptions = { +export const { auth, handlers, signIn, signOut } = NextAuth({ + providers: [ + DiscordProvider({ + clientId: env.DISCORD_CLIENT_ID, + clientSecret: env.DISCORD_CLIENT_SECRET, + }), + ], + adapter: DrizzleAdapter(db, { + usersTable: users, + accountsTable: accounts, + sessionsTable: sessions, + verificationTokensTable: verificationTokens, + }), callbacks: { session: ({ session, user }) => ({ ...session, @@ -52,32 +59,4 @@ export const authOptions: NextAuthOptions = { }, }), }, - adapter: DrizzleAdapter(db, { - usersTable: users, - accountsTable: accounts, - sessionsTable: sessions, - verificationTokensTable: verificationTokens, - }) as Adapter, - providers: [ - DiscordProvider({ - clientId: env.DISCORD_CLIENT_ID, - clientSecret: env.DISCORD_CLIENT_SECRET, - }), - /** - * ...add more providers here. - * - * Most other providers require a bit more work than the Discord provider. For example, the - * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account - * model. Refer to the NextAuth.js docs for the provider you want to use. Example: - * - * @see https://next-auth.js.org/providers/github - */ - ], -}; - -/** - * Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file. - * - * @see https://next-auth.js.org/configuration/nextjs - */ -export const getServerAuthSession = () => getServerSession(authOptions); +}); diff --git a/cli/template/extras/src/server/auth-app/with-prisma.ts b/cli/template/extras/src/server/auth/with-prisma.ts similarity index 56% rename from cli/template/extras/src/server/auth-app/with-prisma.ts rename to cli/template/extras/src/server/auth/with-prisma.ts index 117984c9bd..99ad74997b 100644 --- a/cli/template/extras/src/server/auth-app/with-prisma.ts +++ b/cli/template/extras/src/server/auth/with-prisma.ts @@ -1,10 +1,5 @@ import { PrismaAdapter } from "@auth/prisma-adapter"; -import { - getServerSession, - type DefaultSession, - type NextAuthOptions, -} from "next-auth"; -import { type Adapter } from "next-auth/adapters"; +import NextAuth, { type DefaultSession } from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env"; @@ -36,7 +31,14 @@ declare module "next-auth" { * * @see https://next-auth.js.org/configuration/options */ -export const authOptions: NextAuthOptions = { +export const { auth, handlers, signIn, signOut } = NextAuth({ + providers: [ + DiscordProvider({ + clientId: env.DISCORD_CLIENT_ID, + clientSecret: env.DISCORD_CLIENT_SECRET, + }), + ], + adapter: PrismaAdapter(db), callbacks: { session: ({ session, user }) => ({ ...session, @@ -46,27 +48,4 @@ export const authOptions: NextAuthOptions = { }, }), }, - adapter: PrismaAdapter(db) as Adapter, - providers: [ - DiscordProvider({ - clientId: env.DISCORD_CLIENT_ID, - clientSecret: env.DISCORD_CLIENT_SECRET, - }), - /** - * ...add more providers here. - * - * Most other providers require a bit more work than the Discord provider. For example, the - * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account - * model. Refer to the NextAuth.js docs for the provider you want to use. Example: - * - * @see https://next-auth.js.org/providers/github - */ - ], -}; - -/** - * Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file. - * - * @see https://next-auth.js.org/configuration/nextjs - */ -export const getServerAuthSession = () => getServerSession(authOptions); +}); From 1a8a5a744f394a12ddaf7f6122c9c22d9bdb8911 Mon Sep 17 00:00:00 2001 From: Matvey Ryabchikov <35634442+ronanru@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:54:14 +0300 Subject: [PATCH 03/16] chore: add changeset --- .changeset/grumpy-otters-kneel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/grumpy-otters-kneel.md diff --git a/.changeset/grumpy-otters-kneel.md b/.changeset/grumpy-otters-kneel.md new file mode 100644 index 0000000000..464df113c7 --- /dev/null +++ b/.changeset/grumpy-otters-kneel.md @@ -0,0 +1,5 @@ +--- +"create-t3-app": minor +--- + +update to next.js 15 From 955db2614e66186b1f5d4bff665331d22bbc0f25 Mon Sep 17 00:00:00 2001 From: Matvey Ryabchikov <35634442+ronanru@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:25:46 +0300 Subject: [PATCH 04/16] feat: revert back to the .js config --- cli/src/helpers/createProject.ts | 4 ++-- cli/src/installers/envVars.ts | 4 ++-- .../base/{next.config.ts => next.config.js} | 13 +++++++++---- cli/template/base/src/{env.ts => env.js} | 0 ...{next-config-appdir.ts => next-config-appdir.js} | 7 +++---- 5 files changed, 16 insertions(+), 12 deletions(-) rename cli/template/base/{next.config.ts => next.config.js} (55%) rename cli/template/base/src/{env.ts => env.js} (100%) rename cli/template/extras/config/{next-config-appdir.ts => next-config-appdir.js} (60%) diff --git a/cli/src/helpers/createProject.ts b/cli/src/helpers/createProject.ts index 92aa6ed49e..81b385485f 100644 --- a/cli/src/helpers/createProject.ts +++ b/cli/src/helpers/createProject.ts @@ -64,8 +64,8 @@ export const createProject = async ({ if (appRouter) { // Replace next.config fs.copyFileSync( - path.join(PKG_ROOT, "template/extras/config/next-config-appdir.ts"), - path.join(projectDir, "next.config.ts") + path.join(PKG_ROOT, "template/extras/config/next-config-appdir.js"), + path.join(projectDir, "next.config.js") ); selectLayoutFile({ projectDir, packages }); diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index 281ea7e331..a7377ccf6e 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -44,7 +44,7 @@ export const envVariablesInstaller: Installer = ({ "template/extras/src/env", envFile ); - const envSchemaDest = path.join(projectDir, "src/env.ts"); + const envSchemaDest = path.join(projectDir, "src/env.js"); fs.copyFileSync(envSchemaSrc, envSchemaDest); } @@ -63,7 +63,7 @@ const getEnvContent = ( scopedAppName: string ) => { let content = ` -# When adding additional environment variables, the schema in "/src/env.ts" +# When adding additional environment variables, the schema in "/src/env.js" # should be updated accordingly. ` .trim() diff --git a/cli/template/base/next.config.ts b/cli/template/base/next.config.js similarity index 55% rename from cli/template/base/next.config.ts rename to cli/template/base/next.config.js index a3c840a8ca..98b6f90a51 100644 --- a/cli/template/base/next.config.ts +++ b/cli/template/base/next.config.js @@ -1,18 +1,23 @@ -import { type NextConfig } from "next"; - /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful * for Docker builds. */ -import "./src/env"; +await import("./src/env.js"); +/** @type {import("next").NextConfig} */ const config = { reactStrictMode: true, + + /** + * If you are using `appDir` then you must comment the below `i18n` config out. + * + * @see https://github.com/vercel/next.js/issues/41980 + */ i18n: { locales: ["en"], defaultLocale: "en", }, transpilePackages: ["geist"], -} satisfies NextConfig; +}; export default config; diff --git a/cli/template/base/src/env.ts b/cli/template/base/src/env.js similarity index 100% rename from cli/template/base/src/env.ts rename to cli/template/base/src/env.js diff --git a/cli/template/extras/config/next-config-appdir.ts b/cli/template/extras/config/next-config-appdir.js similarity index 60% rename from cli/template/extras/config/next-config-appdir.ts rename to cli/template/extras/config/next-config-appdir.js index 812e25a83f..9bfe4a0e2a 100644 --- a/cli/template/extras/config/next-config-appdir.ts +++ b/cli/template/extras/config/next-config-appdir.js @@ -1,11 +1,10 @@ -import { type NextConfig } from "next"; - /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful * for Docker builds. */ -import "./src/env"; +await import("./src/env.js"); -const config = {} satisfies NextConfig; +/** @type {import("next").NextConfig} */ +const config = {}; export default config; From 737dc23b612cc65611175566a866523c88922994 Mon Sep 17 00:00:00 2001 From: Matvey Ryabchikov <35634442+ronanru@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:02:37 +0300 Subject: [PATCH 05/16] feat: split nextauth config into a separate file --- cli/src/installers/dependencyVersionMap.ts | 2 +- cli/src/installers/nextAuth.ts | 8 ++++++-- .../src/server/auth/{ => config}/base.ts | 19 ++++++++++++++----- .../server/auth/{ => config}/with-drizzle.ts | 15 ++++++++++++--- .../server/auth/{ => config}/with-prisma.ts | 15 ++++++++++++--- cli/template/extras/src/server/auth/index.ts | 10 ++++++++++ 6 files changed, 55 insertions(+), 14 deletions(-) rename cli/template/extras/src/server/auth/{ => config}/base.ts (62%) rename cli/template/extras/src/server/auth/{ => config}/with-drizzle.ts (72%) rename cli/template/extras/src/server/auth/{ => config}/with-prisma.ts (68%) create mode 100644 cli/template/extras/src/server/auth/index.ts diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index 66f957c40f..b34c1c0b08 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -4,7 +4,7 @@ */ export const dependencyVersionMap = { // NextAuth.js - "next-auth": "beta", + "next-auth": "5.0.0-beta.25", "@auth/prisma-adapter": "^1.6.0", "@auth/drizzle-adapter": "^1.1.0", diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index a3afcc1977..242c8e619b 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -29,15 +29,19 @@ export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const authConfigSrc = path.join( extrasDir, - "src/server/auth", + "src/server/auth/config", usingPrisma ? "with-prisma.ts" : usingDrizzle ? "with-drizzle.ts" : "base.ts" ); - const authConfigDest = path.join(projectDir, "src/server/auth.ts"); + const authConfigDest = path.join(projectDir, "src/server/auth/config.ts"); + + const authIndexSrc = path.join(extrasDir, "src/server/auth/index.ts"); + const authIndexDest = path.join(projectDir, "src/server/auth/index.ts"); fs.copySync(apiHandlerSrc, apiHandlerDest); fs.copySync(authConfigSrc, authConfigDest); + fs.copySync(authIndexSrc, authIndexDest); }; diff --git a/cli/template/extras/src/server/auth/base.ts b/cli/template/extras/src/server/auth/config/base.ts similarity index 62% rename from cli/template/extras/src/server/auth/base.ts rename to cli/template/extras/src/server/auth/config/base.ts index f64b28d47e..081d67347e 100644 --- a/cli/template/extras/src/server/auth/base.ts +++ b/cli/template/extras/src/server/auth/config/base.ts @@ -1,4 +1,4 @@ -import NextAuth, { type DefaultSession } from "next-auth"; +import { type DefaultSession, type NextAuthConfig } from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env"; @@ -29,20 +29,29 @@ declare module "next-auth" { * * @see https://next-auth.js.org/configuration/options */ -export const { auth, handlers, signIn, signOut } = NextAuth({ +export const authConfig = { providers: [ DiscordProvider({ clientId: env.DISCORD_CLIENT_ID, clientSecret: env.DISCORD_CLIENT_SECRET, }), + /** + * ...add more providers here. + * + * Most other providers require a bit more work than the Discord provider. For example, the + * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account + * model. Refer to the NextAuth.js docs for the provider you want to use. Example: + * + * @see https://next-auth.js.org/providers/github + */ ], callbacks: { - session: ({ session, user }) => ({ + session: ({ session, token }) => ({ ...session, user: { ...session.user, - id: user.id, + id: token.sub, }, }), }, -}); +} satisfies NextAuthConfig; diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/config/with-drizzle.ts similarity index 72% rename from cli/template/extras/src/server/auth/with-drizzle.ts rename to cli/template/extras/src/server/auth/config/with-drizzle.ts index 81f31503ec..2ee0691452 100644 --- a/cli/template/extras/src/server/auth/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/config/with-drizzle.ts @@ -1,5 +1,5 @@ import { DrizzleAdapter } from "@auth/drizzle-adapter"; -import NextAuth, { type DefaultSession } from "next-auth"; +import { type DefaultSession, type NextAuthConfig } from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env"; @@ -37,12 +37,21 @@ declare module "next-auth" { * * @see https://next-auth.js.org/configuration/options */ -export const { auth, handlers, signIn, signOut } = NextAuth({ +export const authConfig = { providers: [ DiscordProvider({ clientId: env.DISCORD_CLIENT_ID, clientSecret: env.DISCORD_CLIENT_SECRET, }), + /** + * ...add more providers here. + * + * Most other providers require a bit more work than the Discord provider. For example, the + * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account + * model. Refer to the NextAuth.js docs for the provider you want to use. Example: + * + * @see https://next-auth.js.org/providers/github + */ ], adapter: DrizzleAdapter(db, { usersTable: users, @@ -59,4 +68,4 @@ export const { auth, handlers, signIn, signOut } = NextAuth({ }, }), }, -}); +} satisfies NextAuthConfig; diff --git a/cli/template/extras/src/server/auth/with-prisma.ts b/cli/template/extras/src/server/auth/config/with-prisma.ts similarity index 68% rename from cli/template/extras/src/server/auth/with-prisma.ts rename to cli/template/extras/src/server/auth/config/with-prisma.ts index 99ad74997b..e10c010c52 100644 --- a/cli/template/extras/src/server/auth/with-prisma.ts +++ b/cli/template/extras/src/server/auth/config/with-prisma.ts @@ -1,5 +1,5 @@ import { PrismaAdapter } from "@auth/prisma-adapter"; -import NextAuth, { type DefaultSession } from "next-auth"; +import { type DefaultSession, type NextAuthConfig } from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env"; @@ -31,12 +31,21 @@ declare module "next-auth" { * * @see https://next-auth.js.org/configuration/options */ -export const { auth, handlers, signIn, signOut } = NextAuth({ +export const authConfig = { providers: [ DiscordProvider({ clientId: env.DISCORD_CLIENT_ID, clientSecret: env.DISCORD_CLIENT_SECRET, }), + /** + * ...add more providers here. + * + * Most other providers require a bit more work than the Discord provider. For example, the + * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account + * model. Refer to the NextAuth.js docs for the provider you want to use. Example: + * + * @see https://next-auth.js.org/providers/github + */ ], adapter: PrismaAdapter(db), callbacks: { @@ -48,4 +57,4 @@ export const { auth, handlers, signIn, signOut } = NextAuth({ }, }), }, -}); +} satisfies NextAuthConfig; diff --git a/cli/template/extras/src/server/auth/index.ts b/cli/template/extras/src/server/auth/index.ts new file mode 100644 index 0000000000..76c146d34a --- /dev/null +++ b/cli/template/extras/src/server/auth/index.ts @@ -0,0 +1,10 @@ +import NextAuth from "next-auth"; +import { cache } from "react"; + +import { authConfig } from "./config"; + +const { auth: uncachedAuth, handlers, signIn, signOut } = NextAuth(authConfig); + +const auth = cache(uncachedAuth); + +export { auth, handlers, signIn, signOut }; From 905576c7873c022514f2523a9dbca80192d507a3 Mon Sep 17 00:00:00 2001 From: Matvey Ryabchikov <35634442+ronanru@users.noreply.github.com> Date: Thu, 24 Oct 2024 03:44:16 +0300 Subject: [PATCH 06/16] feat: update env vriables for nextAuth https://x.com/balazsorban44/status/1849132016136036681 --- cli/src/installers/envVars.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index a7377ccf6e..1b68beb5fd 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -101,10 +101,9 @@ DATABASE_URL='mysql://YOUR_MYSQL_URL_HERE?sslaccept=strict'`; content += ` # Next Auth # You can generate a new secret on the command line with: -# openssl rand -base64 32 +# npx auth secret # https://next-auth.js.org/configuration/options#secret -# NEXTAUTH_SECRET="" -NEXTAUTH_URL="http://localhost:3000" +# AUTH_SECRET="" # Next Auth Discord Provider DISCORD_CLIENT_ID="" From 92d59a6def959408b417908525bd88fb57089183 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 26 Oct 2024 12:29:08 +0200 Subject: [PATCH 07/16] update env stuff --- .github/workflows/e2e.yml | 4 +-- cli/src/installers/envVars.ts | 26 +++++++++---------- .../src/env/with-auth-db-planetscale.js | 24 ++++++----------- cli/template/extras/src/env/with-auth-db.js | 22 +++++----------- cli/template/extras/src/env/with-auth.js | 20 +++++--------- www/src/pages/ar/usage/first-steps.md | 2 +- www/src/pages/en/usage/first-steps.md | 2 +- www/src/pages/es/usage/first-steps.md | 2 +- www/src/pages/fr/usage/first-steps.md | 2 +- www/src/pages/ja/usage/first-steps.md | 2 +- www/src/pages/no/usage/first-steps.md | 2 +- www/src/pages/pl/usage/first-steps.md | 2 +- www/src/pages/pt/usage/first-steps.md | 2 +- www/src/pages/ru/usage/first-steps.md | 2 +- www/src/pages/uk/usage/first-steps.md | 2 +- www/src/pages/zh-hans/usage/first-steps.md | 2 +- 16 files changed, 47 insertions(+), 71 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 6d3d590996..3fd90c0e35 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -61,7 +61,7 @@ jobs: - run: cd ../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}}-${{ matrix.appRouter }}-${{ matrix.dbType }} && pnpm build if: ${{ steps.matrix-valid.outputs.continue == 'true' }} env: - NEXTAUTH_SECRET: foo + AUTH_SECRET: foo DISCORD_CLIENT_ID: bar DISCORD_CLIENT_SECRET: baz SKIP_ENV_VALIDATION: true @@ -101,7 +101,7 @@ jobs: - run: cd ../ci-bun && bun run build # - run: cd ../ci-bun && bun --bun run build env: - NEXTAUTH_SECRET: foo + AUTH_SECRET: foo DATABASE_URL: mysql://root:root@localhost:3306/test # can't use url from example env cause we block that in t3-env DISCORD_CLIENT_ID: bar DISCORD_CLIENT_SECRET: baz diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index 1b68beb5fd..a1c4350134 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -69,6 +69,19 @@ const getEnvContent = ( .trim() .concat("\n"); + if (usingAuth) + content += ` + # Next Auth + # You can generate a new secret on the command line with: + # npx auth secret + # https://next-auth.js.org/configuration/options#secret + # AUTH_SECRET="" + + # Next Auth Discord Provider + DISCORD_CLIENT_ID="" + DISCORD_CLIENT_SECRET="" + `; + if (usingPrisma) content += ` # Prisma @@ -97,19 +110,6 @@ DATABASE_URL='mysql://YOUR_MYSQL_URL_HERE?sslaccept=strict'`; content += "\n"; } - if (usingAuth) - content += ` -# Next Auth -# You can generate a new secret on the command line with: -# npx auth secret -# https://next-auth.js.org/configuration/options#secret -# AUTH_SECRET="" - -# Next Auth Discord Provider -DISCORD_CLIENT_ID="" -DISCORD_CLIENT_SECRET="" -`; - if (!usingAuth && !usingPrisma) content += ` # Example: diff --git a/cli/template/extras/src/env/with-auth-db-planetscale.js b/cli/template/extras/src/env/with-auth-db-planetscale.js index 35a053ec5b..bb498142e5 100644 --- a/cli/template/extras/src/env/with-auth-db-planetscale.js +++ b/cli/template/extras/src/env/with-auth-db-planetscale.js @@ -7,6 +7,10 @@ export const env = createEnv({ * isn't built with invalid env vars. */ server: { + AUTH_SECRET: + process.env.NODE_ENV === "production" + ? z.string() + : z.string().optional(), DATABASE_URL: z .string() .url() @@ -14,22 +18,11 @@ export const env = createEnv({ (str) => !str.includes("YOUR_MYSQL_URL_HERE"), "You forgot to change the default URL" ), + DISCORD_CLIENT_ID: z.string(), + DISCORD_CLIENT_SECRET: z.string(), NODE_ENV: z .enum(["development", "test", "production"]) .default("development"), - NEXTAUTH_SECRET: - process.env.NODE_ENV === "production" - ? z.string() - : z.string().optional(), - NEXTAUTH_URL: z.preprocess( - // This makes Vercel deployments not fail if you don't set NEXTAUTH_URL - // Since NextAuth.js automatically uses the VERCEL_URL if present. - (str) => process.env.VERCEL_URL ?? str, - // VERCEL_URL doesn't include `https` so it cant be validated as a URL - process.env.VERCEL ? z.string() : z.string().url() - ), - DISCORD_CLIENT_ID: z.string(), - DISCORD_CLIENT_SECRET: z.string(), }, /** @@ -46,12 +39,11 @@ export const env = createEnv({ * middlewares) or client-side so we need to destruct manually. */ runtimeEnv: { + AUTH_SECRET: process.env.AUTH_SECRET, DATABASE_URL: process.env.DATABASE_URL, - NODE_ENV: process.env.NODE_ENV, - NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET, - NEXTAUTH_URL: process.env.NEXTAUTH_URL, DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET, + NODE_ENV: process.env.NODE_ENV, }, /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially diff --git a/cli/template/extras/src/env/with-auth-db.js b/cli/template/extras/src/env/with-auth-db.js index 2467d22d0f..3491a232bf 100644 --- a/cli/template/extras/src/env/with-auth-db.js +++ b/cli/template/extras/src/env/with-auth-db.js @@ -7,23 +7,16 @@ export const env = createEnv({ * isn't built with invalid env vars. */ server: { - DATABASE_URL: z.string().url(), - NODE_ENV: z - .enum(["development", "test", "production"]) - .default("development"), - NEXTAUTH_SECRET: + AUTH_SECRET: process.env.NODE_ENV === "production" ? z.string() : z.string().optional(), - NEXTAUTH_URL: z.preprocess( - // This makes Vercel deployments not fail if you don't set NEXTAUTH_URL - // Since NextAuth.js automatically uses the VERCEL_URL if present. - (str) => process.env.VERCEL_URL ?? str, - // VERCEL_URL doesn't include `https` so it cant be validated as a URL - process.env.VERCEL ? z.string() : z.string().url() - ), + DATABASE_URL: z.string().url(), DISCORD_CLIENT_ID: z.string(), DISCORD_CLIENT_SECRET: z.string(), + NODE_ENV: z + .enum(["development", "test", "production"]) + .default("development"), }, /** @@ -40,12 +33,11 @@ export const env = createEnv({ * middlewares) or client-side so we need to destruct manually. */ runtimeEnv: { + AUTH_SECRET: process.env.AUTH_SECRET, DATABASE_URL: process.env.DATABASE_URL, - NODE_ENV: process.env.NODE_ENV, - NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET, - NEXTAUTH_URL: process.env.NEXTAUTH_URL, DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET, + NODE_ENV: process.env.NODE_ENV, }, /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially diff --git a/cli/template/extras/src/env/with-auth.js b/cli/template/extras/src/env/with-auth.js index 42cc12648d..cc7a25b728 100644 --- a/cli/template/extras/src/env/with-auth.js +++ b/cli/template/extras/src/env/with-auth.js @@ -7,22 +7,15 @@ export const env = createEnv({ * isn't built with invalid env vars. */ server: { - NODE_ENV: z - .enum(["development", "test", "production"]) - .default("development"), - NEXTAUTH_SECRET: + AUTH_SECRET: process.env.NODE_ENV === "production" ? z.string() : z.string().optional(), - NEXTAUTH_URL: z.preprocess( - // This makes Vercel deployments not fail if you don't set NEXTAUTH_URL - // Since NextAuth.js automatically uses the VERCEL_URL if present. - (str) => process.env.VERCEL_URL ?? str, - // VERCEL_URL doesn't include `https` so it cant be validated as a URL - process.env.VERCEL ? z.string() : z.string().url() - ), DISCORD_CLIENT_ID: z.string(), DISCORD_CLIENT_SECRET: z.string(), + NODE_ENV: z + .enum(["development", "test", "production"]) + .default("development"), }, /** @@ -39,11 +32,10 @@ export const env = createEnv({ * middlewares) or client-side so we need to destruct manually. */ runtimeEnv: { - NODE_ENV: process.env.NODE_ENV, - NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET, - NEXTAUTH_URL: process.env.NEXTAUTH_URL, + AUTH_SECRET: process.env.AUTH_SECRET, DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET, + NODE_ENV: process.env.NODE_ENV, // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR, }, /** diff --git a/www/src/pages/ar/usage/first-steps.md b/www/src/pages/ar/usage/first-steps.md index 813bae3a3f..0fa45d2eea 100644 --- a/www/src/pages/ar/usage/first-steps.md +++ b/www/src/pages/ar/usage/first-steps.md @@ -26,4 +26,4 @@ dir: rtl اضغط علي Reset Secret ثم انسخ كلمة السر الجديدة وضعها في .env كـ DISCORD_CLIENT_SECRET اضغط علي Add Redirect واضف http://localhost:3000/api/auth/callback/discord -اضف NEXTAUTH_SECRET الي .env كـ String، في الـ Production اضف كلمة سر قوية. +اضف AUTH_SECRET الي .env كـ String، في الـ Production اضف كلمة سر قوية. diff --git a/www/src/pages/en/usage/first-steps.md b/www/src/pages/en/usage/first-steps.md index 44e39074c4..e35aecc6c8 100644 --- a/www/src/pages/en/usage/first-steps.md +++ b/www/src/pages/en/usage/first-steps.md @@ -35,7 +35,7 @@ Of course, if you prefer to use a different auth provider, you can also use one 6. Click "Add Redirect" and type in `http://localhost:3000/api/auth/callback/discord`. - For production deployment, follow the previous steps to create another Discord Application, but this time replace `http://localhost:3000` with the URL that you are deploying to. 7. Save Changes. -8. Set the `NEXTAUTH_SECRET` in `.env`. In development any string will work, for production see the note in `.env` on generating a secure secret. +8. Set the `AUTH_SECRET` in `.env`. In development any string will work, for production see the note in `.env` on generating a secure secret. You should now be able to log in. diff --git a/www/src/pages/es/usage/first-steps.md b/www/src/pages/es/usage/first-steps.md index c262a31c28..66eb72248e 100644 --- a/www/src/pages/es/usage/first-steps.md +++ b/www/src/pages/es/usage/first-steps.md @@ -25,7 +25,7 @@ Por supuesto, si prefieres usar un proveedor de autenticación diferente, tambi 6. Haz clic en "Add Redirect" y escribe `http://localhost:3000/api/auth/callback/discord`. - Para la implementación de producción, sigue los pasos anteriores para crear otra aplicación Discord, pero esta vez reemplaza `http://localhost:3000` con la URL de producción en la que está implementando. 7. Guarda los cambios. -8. Configura `NEXTAUTH_SECRET` en `.env`. En desarrollo, cualquier cadena funcionará, para producción, consulta la nota de `.env` sobre la generación de un secreto seguro. +8. Configura `AUTH_SECRET` en `.env`. En desarrollo, cualquier cadena funcionará, para producción, consulta la nota de `.env` sobre la generación de un secreto seguro. Ahora deberías poder iniciar sesión. diff --git a/www/src/pages/fr/usage/first-steps.md b/www/src/pages/fr/usage/first-steps.md index bcb70548f6..b7618fbbaf 100644 --- a/www/src/pages/fr/usage/first-steps.md +++ b/www/src/pages/fr/usage/first-steps.md @@ -26,7 +26,7 @@ Bien sûr, si vous préférez utiliser un autre fournisseur d'authentification, 6. Cliquez sur "Add Redirect" et saisissez `http://localhost:3000/api/auth/callback/discord`. - Pour le déploiement en production, suivez les étapes précédentes pour créer une autre application Discord, mais cette fois remplacez `http://localhost:3000` par l'URL vers laquelle vous déployez. 7. Sauvegarder les modifications. -8. Définissez `NEXTAUTH_SECRET` dans `.env`. En développement, n'importe quelle chaîne fonctionnera, pour la production, voir la note dans `.env` sur la génération d'un secret sécurisé. +8. Définissez `AUTH_SECRET` dans `.env`. En développement, n'importe quelle chaîne fonctionnera, pour la production, voir la note dans `.env` sur la génération d'un secret sécurisé. Vous devriez maintenant pouvoir vous connecter. diff --git a/www/src/pages/ja/usage/first-steps.md b/www/src/pages/ja/usage/first-steps.md index e3c61ca816..852c02c0b1 100644 --- a/www/src/pages/ja/usage/first-steps.md +++ b/www/src/pages/ja/usage/first-steps.md @@ -27,7 +27,7 @@ lang: ja - 本番環境でのデプロイの場合は、前述の手順で別の Discord アプリケーションを作成しますが、今回は`http://localhost:3000`をデプロイ先の URL で置き換えてください。 7. 変更を保存します。 -8. `.env`に`NEXTAUTH_SECRET`を設定します。開発環境では任意の文字列が機能しますが、本番環境では`.env`内のセキュアなシークレット情報の生成に関する注意事項を参照してください。 +8. `.env`に`AUTH_SECRET`を設定します。開発環境では任意の文字列が機能しますが、本番環境では`.env`内のセキュアなシークレット情報の生成に関する注意事項を参照してください。 これでログインできるようになります。 diff --git a/www/src/pages/no/usage/first-steps.md b/www/src/pages/no/usage/first-steps.md index 7b55643071..2001dcee5d 100644 --- a/www/src/pages/no/usage/first-steps.md +++ b/www/src/pages/no/usage/first-steps.md @@ -25,7 +25,7 @@ Hvis du foretrekker en annen autentiseringsleverandør, kan du også bruke en av 6. Klikk "Add Redirect" og skriv inn `http://localhost:3000/api/auth/callback/discord`. - For utrulling i produksjonsmiljø må de foregående trinnene følges på nytt for å lage en annen Discord-applikasjon. Denne gangen erstatt `http://localhost:3000` med URL-en du publiserer til. 7. Lagre endringene. -8. Skriv `NEXTAUTH_SECRET` i `.env`. Hvilken som helst streng vil fungere under utviklingen. For bruk i produksjonsmiljø, ta en titt på notatet i `.env` for å lage en sikker hemmelighetvariabel. +8. Skriv `AUTH_SECRET` i `.env`. Hvilken som helst streng vil fungere under utviklingen. For bruk i produksjonsmiljø, ta en titt på notatet i `.env` for å lage en sikker hemmelighetvariabel. Du skal nå kunne logge på. diff --git a/www/src/pages/pl/usage/first-steps.md b/www/src/pages/pl/usage/first-steps.md index f153968a6a..d50fcec199 100644 --- a/www/src/pages/pl/usage/first-steps.md +++ b/www/src/pages/pl/usage/first-steps.md @@ -33,7 +33,7 @@ Oczywiście, jeżeli wolisz korzystać z innego, możesz użyć jednego z [wielu - Dla deploymentu w wersji produkcyjnej, podążaj za powyższymi krokami aby stworzyć nową aplikację Discord, ale tym razem zamień `http://localhost:3000` na URL, na który wrzucasz swój projekt. 1. Zapisz zmiany -2. Ustaw `NEXTAUTH_SECRET` w pliku `.env`. W wersji rozwojowej zadziała byle co, w wersji produkcyjnej zobacz uwagę w pliku `.env`, która mówi, jak wygenerować bezpieczny secret. +2. Ustaw `AUTH_SECRET` w pliku `.env`. W wersji rozwojowej zadziała byle co, w wersji produkcyjnej zobacz uwagę w pliku `.env`, która mówi, jak wygenerować bezpieczny secret. Powinieneś być w stanie się zalogować. diff --git a/www/src/pages/pt/usage/first-steps.md b/www/src/pages/pt/usage/first-steps.md index a1ba2ef1f4..dd641582cd 100644 --- a/www/src/pages/pt/usage/first-steps.md +++ b/www/src/pages/pt/usage/first-steps.md @@ -25,7 +25,7 @@ Claro, se você preferir usar um provedor de autenticação diferente, também p 6. Clique em "Adicionar redirecionamento" e digite `http://localhost:3000/api/auth/callback/discord`. - Para implantação de produção, siga as etapas anteriores para criar outro aplicativo Discord, mas desta vez substitua `http://localhost:3000` pela URL na qual você está implantando. 7. Salve as alterações. -8. Defina `NEXTAUTH_SECRET` em `.env`. Em desenvolvimento, qualquer string funcionará, para produção, veja a nota em `.env` sobre como gerar um segredo seguro. +8. Defina `AUTH_SECRET` em `.env`. Em desenvolvimento, qualquer string funcionará, para produção, veja a nota em `.env` sobre como gerar um segredo seguro. Agora você deve conseguir fazer login. diff --git a/www/src/pages/ru/usage/first-steps.md b/www/src/pages/ru/usage/first-steps.md index ba31d9cd65..ef4d40c15c 100644 --- a/www/src/pages/ru/usage/first-steps.md +++ b/www/src/pages/ru/usage/first-steps.md @@ -25,7 +25,7 @@ lang: ru 6. Нажмите «Add Redirect» и введите `http://localhost:3000/api/auth/callback/discord`. - Для развертывания в продакшене следуйте предыдущим шагам для создания другого приложения Discord, но на этот раз замените `http://localhost:3000` на URL, на который вы развертываете. 7. Сохраните изменения. -8. Установите `NEXTAUTH_SECRET` в `.env`. В разработке любая строка будет работать, для продакшена см. Примечание в `.env` о генерации безопасного секрета. +8. Установите `AUTH_SECRET` в `.env`. В разработке любая строка будет работать, для продакшена см. Примечание в `.env` о генерации безопасного секрета. Теперь у вас должна быть возможность войти в систему. diff --git a/www/src/pages/uk/usage/first-steps.md b/www/src/pages/uk/usage/first-steps.md index 93166bd242..c9e1b984b6 100644 --- a/www/src/pages/uk/usage/first-steps.md +++ b/www/src/pages/uk/usage/first-steps.md @@ -35,7 +35,7 @@ lang: uk 6. Натисніть "Add Redirect" і введіть `http://localhost:3000/api/auth/callback/discord`. - Для деплойменту в продакшені дотримуйтесь попередніх кроків для створення іншого додатка Discord, але цього разу замініть `http://localhost:3000` на URL, на який ви деплоїте. 7. Збережіть зміни. -8. Встановіть `NEXTAUTH_SECRET` у `.env`. У розробці будь-який рядок працюватиме, для продакшена див. примітка в `.env` про генерацію безпечного secret. +8. Встановіть `AUTH_SECRET` у `.env`. У розробці будь-який рядок працюватиме, для продакшена див. примітка в `.env` про генерацію безпечного secret. Тепер у вас має бути можливість увійти в систему. diff --git a/www/src/pages/zh-hans/usage/first-steps.md b/www/src/pages/zh-hans/usage/first-steps.md index b893e1ee78..0b8e1dbe38 100644 --- a/www/src/pages/zh-hans/usage/first-steps.md +++ b/www/src/pages/zh-hans/usage/first-steps.md @@ -29,7 +29,7 @@ lang: zh-hans 6. 点击 "Add Redirect",然后输入 `http://localhost:3000/api/auth/callback/discord`。 - 对于生产环境的部署,按照之前的步骤来创建另一个 Discord 应用,但是这一次将链接 `http://localhost:3000` 替换为实际生产环境的链接。 7. 保存你的更改。 -8. 在 `.env` 中设置 `NEXTAUTH_SECRET`。在开发过程中,任何字符串都能起效,但对于生产环境,记得查看 `.env` 文件中关于生成安全密钥的注释。 +8. 在 `.env` 中设置 `AUTH_SECRET`。在开发过程中,任何字符串都能起效,但对于生产环境,记得查看 `.env` 文件中关于生成安全密钥的注释。 你现在应该可以登入到你的应用中了。 From b311e5e3bbd0f449567ba8a17d2fcbb41ad6daa4 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 26 Oct 2024 12:31:42 +0200 Subject: [PATCH 08/16] fix indent --- cli/src/installers/envVars.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index a1c4350134..2c9c6f9b0c 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -71,16 +71,16 @@ const getEnvContent = ( if (usingAuth) content += ` - # Next Auth - # You can generate a new secret on the command line with: - # npx auth secret - # https://next-auth.js.org/configuration/options#secret - # AUTH_SECRET="" - - # Next Auth Discord Provider - DISCORD_CLIENT_ID="" - DISCORD_CLIENT_SECRET="" - `; +# Next Auth +# You can generate a new secret on the command line with: +# npx auth secret +# https://next-auth.js.org/configuration/options#secret +# AUTH_SECRET="" + +# Next Auth Discord Provider +DISCORD_CLIENT_ID="" +DISCORD_CLIENT_SECRET="" +`; if (usingPrisma) content += ` From 43ba9923109ba44c14efe5a86f25deccac5fbb9f Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 26 Oct 2024 12:33:31 +0200 Subject: [PATCH 09/16] synchronous import --- cli/template/base/next.config.js | 2 +- cli/template/extras/config/next-config-appdir.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/template/base/next.config.js b/cli/template/base/next.config.js index 98b6f90a51..0eff695958 100644 --- a/cli/template/base/next.config.js +++ b/cli/template/base/next.config.js @@ -2,7 +2,7 @@ * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful * for Docker builds. */ -await import("./src/env.js"); +import "./src/env.js"; /** @type {import("next").NextConfig} */ const config = { diff --git a/cli/template/extras/config/next-config-appdir.js b/cli/template/extras/config/next-config-appdir.js index 9bfe4a0e2a..121c4f4c24 100644 --- a/cli/template/extras/config/next-config-appdir.js +++ b/cli/template/extras/config/next-config-appdir.js @@ -2,7 +2,7 @@ * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful * for Docker builds. */ -await import("./src/env.js"); +import "./src/env.js"; /** @type {import("next").NextConfig} */ const config = {}; From eb4e208c439e5be8adbc7e386191aa011820a34c Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 26 Oct 2024 12:34:53 +0200 Subject: [PATCH 10/16] bump db adapter versions --- cli/src/installers/dependencyVersionMap.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index b34c1c0b08..868214a665 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -5,8 +5,8 @@ export const dependencyVersionMap = { // NextAuth.js "next-auth": "5.0.0-beta.25", - "@auth/prisma-adapter": "^1.6.0", - "@auth/drizzle-adapter": "^1.1.0", + "@auth/prisma-adapter": "^2.7.2", + "@auth/drizzle-adapter": "^1.7.2", // Prisma prisma: "^5.14.0", From 844435ab494dcb8a62c82ee984a7787c01719ca7 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 26 Oct 2024 12:41:19 +0200 Subject: [PATCH 11/16] mjs postcss config is now supported in Next --- cli/src/installers/tailwind.ts | 4 ++-- cli/template/extras/config/_prettier.config.js | 4 +--- cli/template/extras/config/postcss.config.cjs | 7 ------- cli/template/extras/config/postcss.config.js | 5 +++++ www/src/components/docs/folderStructureDiagramApp.astro | 2 +- www/src/components/docs/folderStructureDiagramPages.astro | 2 +- www/src/components/navigation/tableOfContents.astro | 2 +- www/src/pages/ar/folder-structure-pages.mdx | 4 ++-- www/src/pages/en/folder-structure-app.mdx | 4 ++-- www/src/pages/en/folder-structure-pages.mdx | 4 ++-- www/src/pages/es/folder-structure-pages.mdx | 4 ++-- www/src/pages/fr/folder-structure-pages.mdx | 4 ++-- www/src/pages/ja/folder-structure-pages.mdx | 4 ++-- www/src/pages/no/folder-structure-pages.mdx | 4 ++-- www/src/pages/pl/folder-structure-pages.mdx | 4 ++-- www/src/pages/pt/folder-structure-pages.mdx | 4 ++-- www/src/pages/ru/folder-structure-pages.mdx | 4 ++-- www/src/pages/uk/folder-structure-pages.mdx | 4 ++-- www/src/pages/zh-hans/folder-structure-pages.mdx | 4 ++-- 19 files changed, 35 insertions(+), 39 deletions(-) delete mode 100644 cli/template/extras/config/postcss.config.cjs create mode 100644 cli/template/extras/config/postcss.config.js diff --git a/cli/src/installers/tailwind.ts b/cli/src/installers/tailwind.ts index c50ab68dc7..86188a241d 100644 --- a/cli/src/installers/tailwind.ts +++ b/cli/src/installers/tailwind.ts @@ -23,8 +23,8 @@ export const tailwindInstaller: Installer = ({ projectDir }) => { const twCfgSrc = path.join(extrasDir, "config/tailwind.config.ts"); const twCfgDest = path.join(projectDir, "tailwind.config.ts"); - const postcssCfgSrc = path.join(extrasDir, "config/postcss.config.cjs"); - const postcssCfgDest = path.join(projectDir, "postcss.config.cjs"); + const postcssCfgSrc = path.join(extrasDir, "config/postcss.config.js"); + const postcssCfgDest = path.join(projectDir, "postcss.config.js"); const prettierSrc = path.join(extrasDir, "config/_prettier.config.js"); const prettierDest = path.join(projectDir, "prettier.config.js"); diff --git a/cli/template/extras/config/_prettier.config.js b/cli/template/extras/config/_prettier.config.js index b2d59b460f..da332bd898 100644 --- a/cli/template/extras/config/_prettier.config.js +++ b/cli/template/extras/config/_prettier.config.js @@ -1,6 +1,4 @@ /** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */ -const config = { +export default { plugins: ["prettier-plugin-tailwindcss"], }; - -export default config; diff --git a/cli/template/extras/config/postcss.config.cjs b/cli/template/extras/config/postcss.config.cjs deleted file mode 100644 index 4cdb2f430f..0000000000 --- a/cli/template/extras/config/postcss.config.cjs +++ /dev/null @@ -1,7 +0,0 @@ -const config = { - plugins: { - tailwindcss: {}, - }, -}; - -module.exports = config; diff --git a/cli/template/extras/config/postcss.config.js b/cli/template/extras/config/postcss.config.js new file mode 100644 index 0000000000..01bf7432f6 --- /dev/null +++ b/cli/template/extras/config/postcss.config.js @@ -0,0 +1,5 @@ +export default { + plugins: { + tailwindcss: {}, + }, +}; diff --git a/www/src/components/docs/folderStructureDiagramApp.astro b/www/src/components/docs/folderStructureDiagramApp.astro index 0b175db152..68e9690737 100644 --- a/www/src/components/docs/folderStructureDiagramApp.astro +++ b/www/src/components/docs/folderStructureDiagramApp.astro @@ -41,7 +41,7 @@ "next-env.d.ts": [], "next.config.js": [], "package.json": [], - "postcss.config.cjs": ["tailwind"], + "postcss.config.js": ["tailwind"], "prettier.config.js": ["tailwind"], "README.md": [], "start-database.sh (mysql or postgres only)": ["drizzle"], diff --git a/www/src/components/docs/folderStructureDiagramPages.astro b/www/src/components/docs/folderStructureDiagramPages.astro index 8676e66019..8756fb6f4c 100644 --- a/www/src/components/docs/folderStructureDiagramPages.astro +++ b/www/src/components/docs/folderStructureDiagramPages.astro @@ -38,7 +38,7 @@ "next-env.d.ts": [], "next.config.js": [], "package.json": [], - "postcss.config.cjs": ["tailwind"], + "postcss.config.js": ["tailwind"], "prettier.config.js": ["tailwind"], "README.md": [], "start-database.sh (mysql or postgres only)": ["drizzle"], diff --git a/www/src/components/navigation/tableOfContents.astro b/www/src/components/navigation/tableOfContents.astro index 65b9ad134f..fed095ffe8 100644 --- a/www/src/components/navigation/tableOfContents.astro +++ b/www/src/components/navigation/tableOfContents.astro @@ -39,7 +39,7 @@ const isRtl = getIsRtlFromUrl(pathname); case "src/server/auth.ts": dataComponentType = "nextauth"; break; - case "postcss.config.cjs": + case "postcss.config.js": case "prettier.config.mjs": dataComponentType = "tailwind"; break; diff --git a/www/src/pages/ar/folder-structure-pages.mdx b/www/src/pages/ar/folder-structure-pages.mdx index aafcc4f850..95ddbefc07 100644 --- a/www/src/pages/ar/folder-structure-pages.mdx +++ b/www/src/pages/ar/folder-structure-pages.mdx @@ -198,9 +198,9 @@ import Form from "../../components/docs/folderStructureForm.astro";
-### `postcss.config.cjs` +### `postcss.config.js` -إن ملف `postcss.config.cjs` ضروري عند استخدام TailwindCSS PostCSS، لمزيد من المعلومات [Taiwind PostCSS Docs](https://tailwindcss.com/docs/installation/using-postcss). +إن ملف `postcss.config.js` ضروري عند استخدام TailwindCSS PostCSS، لمزيد من المعلومات [Taiwind PostCSS Docs](https://tailwindcss.com/docs/installation/using-postcss).
diff --git a/www/src/pages/en/folder-structure-app.mdx b/www/src/pages/en/folder-structure-app.mdx index 2c15167216..3005ddb419 100644 --- a/www/src/pages/en/folder-structure-app.mdx +++ b/www/src/pages/en/folder-structure-app.mdx @@ -226,9 +226,9 @@ The `next.config.mjs` file is used to configure Next.js. See [Next.js Docs](http
-### `postcss.config.cjs` +### `postcss.config.js` -The `postcss.config.cjs` file is used for Tailwind PostCSS usage. See [Tailwind PostCSS Docs](https://tailwindcss.com/docs/installation/using-postcss) for more information. +The `postcss.config.js` file is used for Tailwind PostCSS usage. See [Tailwind PostCSS Docs](https://tailwindcss.com/docs/installation/using-postcss) for more information.
diff --git a/www/src/pages/en/folder-structure-pages.mdx b/www/src/pages/en/folder-structure-pages.mdx index 9cad8be65b..47d7c35a6f 100644 --- a/www/src/pages/en/folder-structure-pages.mdx +++ b/www/src/pages/en/folder-structure-pages.mdx @@ -219,9 +219,9 @@ The `next.config.mjs` file is used to configure Next.js. See [Next.js Docs](http
-### `postcss.config.cjs` +### `postcss.config.js` -The `postcss.config.cjs` file is used for Tailwind PostCSS usage. See [Tailwind PostCSS Docs](https://tailwindcss.com/docs/installation/using-postcss) for more information. +The `postcss.config.js` file is used for Tailwind PostCSS usage. See [Tailwind PostCSS Docs](https://tailwindcss.com/docs/installation/using-postcss) for more information.
diff --git a/www/src/pages/es/folder-structure-pages.mdx b/www/src/pages/es/folder-structure-pages.mdx index 53f5298121..38017f3cc3 100644 --- a/www/src/pages/es/folder-structure-pages.mdx +++ b/www/src/pages/es/folder-structure-pages.mdx @@ -206,9 +206,9 @@ El archivo `next.config.mjs` se usa para configurar Next.js. Consulta [la docume
-### `postcss.config.cjs` +### `postcss.config.js` -El archivo `postcss.config.cjs` se usa para la configuración de Tailwind PostCSS. Consulta [la documentación de Tailwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss) para obtener más información. +El archivo `postcss.config.js` se usa para la configuración de Tailwind PostCSS. Consulta [la documentación de Tailwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss) para obtener más información.
diff --git a/www/src/pages/fr/folder-structure-pages.mdx b/www/src/pages/fr/folder-structure-pages.mdx index cd85a7e057..bf54572dd2 100644 --- a/www/src/pages/fr/folder-structure-pages.mdx +++ b/www/src/pages/fr/folder-structure-pages.mdx @@ -197,9 +197,9 @@ Le fichier `next.config.mjs` est utilisé pour configurer Next.js. Voir la [docu
-### `postcss.config.cjs` +### `postcss.config.js` -Le fichier `postcss.config.cjs` est utilisé pour l'utilisation de Tailwind PostCSS. Voir la [documentation de Tailwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss) pour plus d'informations. +Le fichier `postcss.config.js` est utilisé pour l'utilisation de Tailwind PostCSS. Voir la [documentation de Tailwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss) pour plus d'informations.
diff --git a/www/src/pages/ja/folder-structure-pages.mdx b/www/src/pages/ja/folder-structure-pages.mdx index 649ad650f7..57482b1024 100644 --- a/www/src/pages/ja/folder-structure-pages.mdx +++ b/www/src/pages/ja/folder-structure-pages.mdx @@ -187,9 +187,9 @@ import Form from "../../components/docs/folderStructureForm.astro";
-### `postcss.config.cjs` +### `postcss.config.js` -Tailwind の PostCSS の利用には、`postcss.config.cjs`ファイルが使用されます。詳しくは[Tailwind PostCSS Docs](https://tailwindcss.com/docs/installation/using-postcss)を参照してください。 +Tailwind の PostCSS の利用には、`postcss.config.js`ファイルが使用されます。詳しくは[Tailwind PostCSS Docs](https://tailwindcss.com/docs/installation/using-postcss)を参照してください。
diff --git a/www/src/pages/no/folder-structure-pages.mdx b/www/src/pages/no/folder-structure-pages.mdx index 5d08f774cf..b77fd3820c 100644 --- a/www/src/pages/no/folder-structure-pages.mdx +++ b/www/src/pages/no/folder-structure-pages.mdx @@ -183,9 +183,9 @@ Basert på dine valgte pakker inneholder denne ruteren flere eller færre ruter
-### `postcss.config.cjs` +### `postcss.config.js` -`postcss.config.cjs`-filen er for bruk av Tailwind PostCSS. Se [Tailwind PostCSS Docs](https://tailwindcss.com/docs/installation/using-postcss) for mer informasjon. +`postcss.config.js`-filen er for bruk av Tailwind PostCSS. Se [Tailwind PostCSS Docs](https://tailwindcss.com/docs/installation/using-postcss) for mer informasjon.
diff --git a/www/src/pages/pl/folder-structure-pages.mdx b/www/src/pages/pl/folder-structure-pages.mdx index 1a57fcdf80..0d935b79c6 100644 --- a/www/src/pages/pl/folder-structure-pages.mdx +++ b/www/src/pages/pl/folder-structure-pages.mdx @@ -184,9 +184,9 @@ Plik `next.config.mjs` jest używany do konfigurowania Next.js. Po więcej infor
-### `postcss.config.cjs` +### `postcss.config.js` -Plik `postcss.config.cjs` jest używany przez Tailwind PostCSS. Po więcej informacji, zobacz [dokumentację Tailwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss). +Plik `postcss.config.js` jest używany przez Tailwind PostCSS. Po więcej informacji, zobacz [dokumentację Tailwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss).
diff --git a/www/src/pages/pt/folder-structure-pages.mdx b/www/src/pages/pt/folder-structure-pages.mdx index f88fdd5fe7..0dad871dfe 100644 --- a/www/src/pages/pt/folder-structure-pages.mdx +++ b/www/src/pages/pt/folder-structure-pages.mdx @@ -198,9 +198,9 @@ O arquivo `next.config.mjs` é usado para configura o Next.js. Veja [Documentaç
-### `postcss.config.cjs` +### `postcss.config.js` -O arquivo `postcss.config.cjs` é usado para o uso do Tailwind PostCSS. Veja [Documentação do Tailwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss) para mais informações. +O arquivo `postcss.config.js` é usado para o uso do Tailwind PostCSS. Veja [Documentação do Tailwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss) para mais informações.
diff --git a/www/src/pages/ru/folder-structure-pages.mdx b/www/src/pages/ru/folder-structure-pages.mdx index 16e12e3b47..4ecfa05442 100644 --- a/www/src/pages/ru/folder-structure-pages.mdx +++ b/www/src/pages/ru/folder-structure-pages.mdx @@ -198,9 +198,9 @@ import Form from "../../components/docs/folderStructureForm.astro";
-### `postcss.config.cjs` +### `postcss.config.js` -Файл `postcss.config.cjs` используется для использования Tailwind PostCSS. Смотрите [документацию Taiwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss) для получения дополнительной информации. +Файл `postcss.config.js` используется для использования Tailwind PostCSS. Смотрите [документацию Taiwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss) для получения дополнительной информации.
diff --git a/www/src/pages/uk/folder-structure-pages.mdx b/www/src/pages/uk/folder-structure-pages.mdx index 9fdbedf015..bb1662d4bf 100644 --- a/www/src/pages/uk/folder-structure-pages.mdx +++ b/www/src/pages/uk/folder-structure-pages.mdx @@ -198,9 +198,9 @@ import Form from "../../components/docs/folderStructureForm.astro";
-### `postcss.config.cjs` +### `postcss.config.js` -Файл `postcss.config.cjs` використовується для використання Tailwind PostCSS. Дивіться [документацію Taiwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss) для отримання додаткової інформації. +Файл `postcss.config.js` використовується для використання Tailwind PostCSS. Дивіться [документацію Taiwind PostCSS](https://tailwindcss.com/docs/installation/using-postcss) для отримання додаткової інформації.
diff --git a/www/src/pages/zh-hans/folder-structure-pages.mdx b/www/src/pages/zh-hans/folder-structure-pages.mdx index 3ceb055d52..ce2fb44ad8 100644 --- a/www/src/pages/zh-hans/folder-structure-pages.mdx +++ b/www/src/pages/zh-hans/folder-structure-pages.mdx @@ -185,9 +185,9 @@ root.ts 文件用于合并 tRPC 子路由并将它们导出为一个单一的路
-### `postcss.config.cjs` +### `postcss.config.js` -文件 `postcss.config.cjs` 被用于配置 Tailwind PostCSS 的用法。参看 [Tailwind PostCSS 文档](https://tailwindcss.com/docs/installation/using-postcss) 来了解更多。 +文件 `postcss.config.js` 被用于配置 Tailwind PostCSS 的用法。参看 [Tailwind PostCSS 文档](https://tailwindcss.com/docs/installation/using-postcss) 来了解更多。
From 8b2da551019826f7d6cfffee9bbb4d6fe3cc95fd Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 26 Oct 2024 12:55:43 +0200 Subject: [PATCH 12/16] use new auth secret format --- .github/workflows/e2e.yml | 8 +++---- cli/src/installers/envVars.ts | 21 ++++++++++++++----- .../src/env/with-auth-db-planetscale.js | 8 +++---- cli/template/extras/src/env/with-auth-db.js | 8 +++---- cli/template/extras/src/env/with-auth.js | 8 +++---- .../extras/src/server/auth/config/base.ts | 7 +------ .../src/server/auth/config/with-drizzle.ts | 6 +----- .../src/server/auth/config/with-prisma.ts | 6 +----- www/src/pages/ar/usage/first-steps.md | 4 ++-- www/src/pages/ar/usage/next-auth.md | 4 ++-- www/src/pages/en/usage/first-steps.md | 4 ++-- www/src/pages/en/usage/next-auth.mdx | 4 ++-- www/src/pages/es/usage/first-steps.md | 4 ++-- www/src/pages/es/usage/next-auth.md | 4 ++-- www/src/pages/fr/usage/first-steps.md | 2 +- www/src/pages/fr/usage/next-auth.mdx | 2 +- www/src/pages/ja/usage/first-steps.md | 4 ++-- www/src/pages/ja/usage/next-auth.md | 4 ++-- www/src/pages/no/usage/first-steps.md | 4 ++-- www/src/pages/no/usage/next-auth.md | 4 ++-- www/src/pages/pl/usage/first-steps.md | 4 ++-- www/src/pages/pl/usage/next-auth.md | 4 ++-- www/src/pages/pt/usage/first-steps.md | 4 ++-- www/src/pages/pt/usage/next-auth.md | 4 ++-- www/src/pages/ru/usage/first-steps.md | 4 ++-- www/src/pages/ru/usage/next-auth.md | 4 ++-- www/src/pages/uk/usage/first-steps.md | 4 ++-- www/src/pages/uk/usage/next-auth.mdx | 4 ++-- www/src/pages/zh-hans/usage/first-steps.md | 4 ++-- www/src/pages/zh-hans/usage/next-auth.mdx | 4 ++-- 30 files changed, 77 insertions(+), 79 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 3fd90c0e35..ae0d0fc562 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -62,8 +62,8 @@ jobs: if: ${{ steps.matrix-valid.outputs.continue == 'true' }} env: AUTH_SECRET: foo - DISCORD_CLIENT_ID: bar - DISCORD_CLIENT_SECRET: baz + AUTH_DISCORD_ID: bar + AUTH_DISCORD_SECRET: baz SKIP_ENV_VALIDATION: true build-t3-app-with-bun: @@ -102,6 +102,6 @@ jobs: # - run: cd ../ci-bun && bun --bun run build env: AUTH_SECRET: foo + AUTH_DISCORD_ID: bar + AUTH_DISCORD_SECRET: baz DATABASE_URL: mysql://root:root@localhost:3306/test # can't use url from example env cause we block that in t3-env - DISCORD_CLIENT_ID: bar - DISCORD_CLIENT_SECRET: baz diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index 2c9c6f9b0c..6288fab1b5 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -51,8 +51,19 @@ export const envVariablesInstaller: Installer = ({ const envDest = path.join(projectDir, ".env"); const envExampleDest = path.join(projectDir, ".env.example"); - fs.writeFileSync(envDest, envContent, "utf-8"); - fs.writeFileSync(envExampleDest, exampleEnvContent + envContent, "utf-8"); + const _exampleEnvContent = exampleEnvContent + envContent; + + // Generate an auth secret and put in .env, not .env.example + const secret = Buffer.from( + crypto.getRandomValues(new Uint8Array(32)) + ).toString("base64"); + const _envContent = envContent.replace( + 'AUTH_SECRET=""', + `AUTH_SECRET="${secret}" # Generated by create-t3-app.` + ); + + fs.writeFileSync(envDest, _envContent, "utf-8"); + fs.writeFileSync(envExampleDest, _exampleEnvContent, "utf-8"); }; const getEnvContent = ( @@ -75,11 +86,11 @@ const getEnvContent = ( # You can generate a new secret on the command line with: # npx auth secret # https://next-auth.js.org/configuration/options#secret -# AUTH_SECRET="" +AUTH_SECRET="" # Next Auth Discord Provider -DISCORD_CLIENT_ID="" -DISCORD_CLIENT_SECRET="" +AUTH_DISCORD_ID="" +AUTH_DISCORD_SECRET="" `; if (usingPrisma) diff --git a/cli/template/extras/src/env/with-auth-db-planetscale.js b/cli/template/extras/src/env/with-auth-db-planetscale.js index bb498142e5..01abd8e6f1 100644 --- a/cli/template/extras/src/env/with-auth-db-planetscale.js +++ b/cli/template/extras/src/env/with-auth-db-planetscale.js @@ -11,6 +11,8 @@ export const env = createEnv({ process.env.NODE_ENV === "production" ? z.string() : z.string().optional(), + AUTH_DISCORD_ID: z.string(), + AUTH_DISCORD_SECRET: z.string(), DATABASE_URL: z .string() .url() @@ -18,8 +20,6 @@ export const env = createEnv({ (str) => !str.includes("YOUR_MYSQL_URL_HERE"), "You forgot to change the default URL" ), - DISCORD_CLIENT_ID: z.string(), - DISCORD_CLIENT_SECRET: z.string(), NODE_ENV: z .enum(["development", "test", "production"]) .default("development"), @@ -40,9 +40,9 @@ export const env = createEnv({ */ runtimeEnv: { AUTH_SECRET: process.env.AUTH_SECRET, + AUTH_DISCORD_ID: process.env.AUTH_DISCORD_ID, + AUTH_DISCORD_SECRET: process.env.AUTH_DISCORD_SECRET, DATABASE_URL: process.env.DATABASE_URL, - DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID, - DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET, NODE_ENV: process.env.NODE_ENV, }, /** diff --git a/cli/template/extras/src/env/with-auth-db.js b/cli/template/extras/src/env/with-auth-db.js index 3491a232bf..6b19f72401 100644 --- a/cli/template/extras/src/env/with-auth-db.js +++ b/cli/template/extras/src/env/with-auth-db.js @@ -11,9 +11,9 @@ export const env = createEnv({ process.env.NODE_ENV === "production" ? z.string() : z.string().optional(), + AUTH_DISCORD_ID: z.string(), + AUTH_DISCORD_SECRET: z.string(), DATABASE_URL: z.string().url(), - DISCORD_CLIENT_ID: z.string(), - DISCORD_CLIENT_SECRET: z.string(), NODE_ENV: z .enum(["development", "test", "production"]) .default("development"), @@ -34,9 +34,9 @@ export const env = createEnv({ */ runtimeEnv: { AUTH_SECRET: process.env.AUTH_SECRET, + AUTH_DISCORD_ID: process.env.AUTH_DISCORD_ID, + AUTH_DISCORD_SECRET: process.env.AUTH_DISCORD_SECRET, DATABASE_URL: process.env.DATABASE_URL, - DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID, - DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET, NODE_ENV: process.env.NODE_ENV, }, /** diff --git a/cli/template/extras/src/env/with-auth.js b/cli/template/extras/src/env/with-auth.js index cc7a25b728..45b5cba0a3 100644 --- a/cli/template/extras/src/env/with-auth.js +++ b/cli/template/extras/src/env/with-auth.js @@ -11,8 +11,8 @@ export const env = createEnv({ process.env.NODE_ENV === "production" ? z.string() : z.string().optional(), - DISCORD_CLIENT_ID: z.string(), - DISCORD_CLIENT_SECRET: z.string(), + AUTH_DISCORD_ID: z.string(), + AUTH_DISCORD_SECRET: z.string(), NODE_ENV: z .enum(["development", "test", "production"]) .default("development"), @@ -33,8 +33,8 @@ export const env = createEnv({ */ runtimeEnv: { AUTH_SECRET: process.env.AUTH_SECRET, - DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID, - DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET, + AUTH_DISCORD_ID: process.env.AUTH_DISCORD_ID, + AUTH_DISCORD_SECRET: process.env.AUTH_DISCORD_SECRET, NODE_ENV: process.env.NODE_ENV, // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR, }, diff --git a/cli/template/extras/src/server/auth/config/base.ts b/cli/template/extras/src/server/auth/config/base.ts index 081d67347e..c88101a0b4 100644 --- a/cli/template/extras/src/server/auth/config/base.ts +++ b/cli/template/extras/src/server/auth/config/base.ts @@ -1,8 +1,6 @@ import { type DefaultSession, type NextAuthConfig } from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; -import { env } from "~/env"; - /** * Module augmentation for `next-auth` types. Allows us to add custom properties to the `session` * object and keep type safety. @@ -31,10 +29,7 @@ declare module "next-auth" { */ export const authConfig = { providers: [ - DiscordProvider({ - clientId: env.DISCORD_CLIENT_ID, - clientSecret: env.DISCORD_CLIENT_SECRET, - }), + DiscordProvider, /** * ...add more providers here. * diff --git a/cli/template/extras/src/server/auth/config/with-drizzle.ts b/cli/template/extras/src/server/auth/config/with-drizzle.ts index 2ee0691452..3ef82a2f63 100644 --- a/cli/template/extras/src/server/auth/config/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/config/with-drizzle.ts @@ -2,7 +2,6 @@ import { DrizzleAdapter } from "@auth/drizzle-adapter"; import { type DefaultSession, type NextAuthConfig } from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; -import { env } from "~/env"; import { db } from "~/server/db"; import { accounts, @@ -39,10 +38,7 @@ declare module "next-auth" { */ export const authConfig = { providers: [ - DiscordProvider({ - clientId: env.DISCORD_CLIENT_ID, - clientSecret: env.DISCORD_CLIENT_SECRET, - }), + DiscordProvider, /** * ...add more providers here. * diff --git a/cli/template/extras/src/server/auth/config/with-prisma.ts b/cli/template/extras/src/server/auth/config/with-prisma.ts index e10c010c52..9b8ec7997f 100644 --- a/cli/template/extras/src/server/auth/config/with-prisma.ts +++ b/cli/template/extras/src/server/auth/config/with-prisma.ts @@ -2,7 +2,6 @@ import { PrismaAdapter } from "@auth/prisma-adapter"; import { type DefaultSession, type NextAuthConfig } from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; -import { env } from "~/env"; import { db } from "~/server/db"; /** @@ -33,10 +32,7 @@ declare module "next-auth" { */ export const authConfig = { providers: [ - DiscordProvider({ - clientId: env.DISCORD_CLIENT_ID, - clientSecret: env.DISCORD_CLIENT_SECRET, - }), + DiscordProvider, /** * ...add more providers here. * diff --git a/www/src/pages/ar/usage/first-steps.md b/www/src/pages/ar/usage/first-steps.md index 0fa45d2eea..a75cbca37a 100644 --- a/www/src/pages/ar/usage/first-steps.md +++ b/www/src/pages/ar/usage/first-steps.md @@ -22,8 +22,8 @@ dir: rtl ثم اذهب **<** Settings **<** OAuth2 **<** General -قم بنسخ Client ID وضعه في `.env `كـ `DISCORD_CLIENT_ID` +قم بنسخ Client ID وضعه في `.env `كـ `AUTH_DISCORD_ID` -اضغط علي Reset Secret ثم انسخ كلمة السر الجديدة وضعها في .env كـ DISCORD_CLIENT_SECRET +اضغط علي Reset Secret ثم انسخ كلمة السر الجديدة وضعها في .env كـ AUTH_DISCORD_SECRET اضغط علي Add Redirect واضف http://localhost:3000/api/auth/callback/discord اضف AUTH_SECRET الي .env كـ String، في الـ Production اضف كلمة سر قوية. diff --git a/www/src/pages/ar/usage/next-auth.md b/www/src/pages/ar/usage/next-auth.md index 565ef7be0d..8d65fb8a71 100644 --- a/www/src/pages/ar/usage/next-auth.md +++ b/www/src/pages/ar/usage/next-auth.md @@ -159,9 +159,9 @@ const userRouter = router({ 2. في settings menu اضغط على OAuth2 ثم General -3. إنسخ الـ Client ID وضعة في `.env` كـ DISCORD_CLIENT_ID +3. إنسخ الـ Client ID وضعة في `.env` كـ AUTH_DISCORD_ID -4. تحت Client Secret اضغط على "Reset Secret" ونسخ النص الجديد وضعه في `.env` كـ `DISCORD_CLIENT_SECRET `. +4. تحت Client Secret اضغط على "Reset Secret" ونسخ النص الجديد وضعه في `.env` كـ `AUTH_DISCORD_SECRET `. كن حذرًا لأنك لن تتمكن من رؤية هذا كلمة السر مرة أخرى ، ستؤدي إعادة تعيينها إلى انتهاء صلاحية كلمة السر الحالية 5. اضغط على Add Redirect واضف رابط إعادة التوجيه`http://localhost:3000/api/auth/callback/discord` كمثال 6. احفظ التعديلات diff --git a/www/src/pages/en/usage/first-steps.md b/www/src/pages/en/usage/first-steps.md index e35aecc6c8..6f7af9b0c2 100644 --- a/www/src/pages/en/usage/first-steps.md +++ b/www/src/pages/en/usage/first-steps.md @@ -30,8 +30,8 @@ Of course, if you prefer to use a different auth provider, you can also use one 1. You will need a Discord account, so register one if you haven't already. 2. Navigate to https://discord.com/developers/applications and click "New Application" in the top right corner. Give your application a name and agree to the Terms of Service. 3. Once your application has been created, navigate to "Settings → OAuth2 → General". -4. Copy the "Client ID" and add it to your `.env` as `DISCORD_CLIENT_ID`. -5. Click "Reset Secret", copy the new secret, and add it to your `.env` as `DISCORD_CLIENT_SECRET`. +4. Copy the "Client ID" and add it to your `.env` as `AUTH_DISCORD_ID`. +5. Click "Reset Secret", copy the new secret, and add it to your `.env` as `AUTH_DISCORD_SECRET`. 6. Click "Add Redirect" and type in `http://localhost:3000/api/auth/callback/discord`. - For production deployment, follow the previous steps to create another Discord Application, but this time replace `http://localhost:3000` with the URL that you are deploying to. 7. Save Changes. diff --git a/www/src/pages/en/usage/next-auth.mdx b/www/src/pages/en/usage/next-auth.mdx index 7a5d68d5b0..9a0b41e8fb 100644 --- a/www/src/pages/en/usage/next-auth.mdx +++ b/www/src/pages/en/usage/next-auth.mdx @@ -213,8 +213,8 @@ I.e.: 1. Head to [the Applications section in the Discord Developer Portal](https://discord.com/developers/applications), and click on "New Application" 2. In the settings menu, go to "OAuth2 => General" -- Copy the Client ID and paste it in `DISCORD_CLIENT_ID` in `.env`. -- Under Client Secret, click "Reset Secret" and copy that string to `DISCORD_CLIENT_SECRET` in `.env`. Be careful as you won't be able to see this secret again, and resetting it will cause the existing one to expire. +- Copy the Client ID and paste it in `AUTH_DISCORD_ID` in `.env`. +- Under Client Secret, click "Reset Secret" and copy that string to `AUTH_DISCORD_SECRET` in `.env`. Be careful as you won't be able to see this secret again, and resetting it will cause the existing one to expire. - Click "Add Redirect" and paste in `/api/auth/callback/discord` (example for local development: http://localhost:3000/api/auth/callback/discord) - Save your changes - It is possible, but not recommended, to use the same Discord Application for both development and production. You could also consider [Mocking the Provider](https://github.com/trpc/trpc/blob/main/examples/next-prisma-websockets-starter/src/pages/api/auth/%5B...nextauth%5D.ts) during development. diff --git a/www/src/pages/es/usage/first-steps.md b/www/src/pages/es/usage/first-steps.md index 66eb72248e..8e91fe7b3e 100644 --- a/www/src/pages/es/usage/first-steps.md +++ b/www/src/pages/es/usage/first-steps.md @@ -20,8 +20,8 @@ Por supuesto, si prefieres usar un proveedor de autenticación diferente, tambi 1. Necesitarás una cuenta de Discord, así que crea una cuenta si aún no lo has hecho. 2. Dirígite a [https://discord.com/developers/applications](https://discord.com/developers/applications) y haz clic en "New Application" en la esquina superior derecha. Asigna un nombre a tu aplicación y acepta los términos de servicio. 3. Una vez creada tu aplicación, dirígite a "Settings → OAuth2 → General". -4. Copia el "Client ID" y agrégalo a tu `.env` como `DISCORD_CLIENT_ID`. -5. Haz clic en "Reset Secret", copia el nuevo valor secreto y agrégalo a tu `.env` como `DISCORD_CLIENT_SECRET`. +4. Copia el "Client ID" y agrégalo a tu `.env` como `AUTH_DISCORD_ID`. +5. Haz clic en "Reset Secret", copia el nuevo valor secreto y agrégalo a tu `.env` como `AUTH_DISCORD_SECRET`. 6. Haz clic en "Add Redirect" y escribe `http://localhost:3000/api/auth/callback/discord`. - Para la implementación de producción, sigue los pasos anteriores para crear otra aplicación Discord, pero esta vez reemplaza `http://localhost:3000` con la URL de producción en la que está implementando. 7. Guarda los cambios. diff --git a/www/src/pages/es/usage/next-auth.md b/www/src/pages/es/usage/next-auth.md index 27a17a3eb6..ffc7be4b9b 100644 --- a/www/src/pages/es/usage/next-auth.md +++ b/www/src/pages/es/usage/next-auth.md @@ -158,8 +158,8 @@ El uso de NextAuth.js con el middleware Next.js [requiere el uso de la estrategi 1. Dirígete a [la sección de aplicaciones en el portal del desarrollador de Discord](https://discord.com/developers/applications) y haz clic en "New Application" 2. En el menú de configuración, dirígite a "OAuth2 => General" -- Copia el Client ID y pégalo en `DISCORD_CLIENT_ID` en `.env`. -- En Client Secret, haz clic en "Reset Secret" y copia ese string en `DISCORD_CLIENT_SECRET` en `.env`. Ten cuidado ya que no podrás volver a ver este valor secreto, y restablecerlo hará que el existente expire. +- Copia el Client ID y pégalo en `AUTH_DISCORD_ID` en `.env`. +- En Client Secret, haz clic en "Reset Secret" y copia ese string en `AUTH_DISCORD_SECRET` en `.env`. Ten cuidado ya que no podrás volver a ver este valor secreto, y restablecerlo hará que el existente expire. - Haz clic en "Add Redirect" y pega en `/api/auth/callback/discord` (Ejemplo para desarrollo local: http://localhost:3000/api/auth/callback/discord) - Guarda tus cambios - Es posible, pero no recomendado, usar la misma aplicación de Discord tanto para desarrollo como para producción. También puedes considerar hacer un [mock del proveedor](https://github.com/trpc/trpc/blob/main/examples/next-prisma-websockets-starter/src/pages/api/auth/%5B...nextauth%5D.ts) durante el desarrollo. diff --git a/www/src/pages/fr/usage/first-steps.md b/www/src/pages/fr/usage/first-steps.md index b7618fbbaf..d1d105a44d 100644 --- a/www/src/pages/fr/usage/first-steps.md +++ b/www/src/pages/fr/usage/first-steps.md @@ -21,7 +21,7 @@ Bien sûr, si vous préférez utiliser un autre fournisseur d'authentification, 1. Vous aurez besoin d'un compte Discord, créez-en un si vous ne l'avez pas déjà fait. 2. Accédez à https://discord.com/developers/applications et cliquez sur "New Application" dans le coin supérieur droit. Nommez votre application et acceptez les conditions d'utilisation. 3. Une fois votre application créée, accédez à "Settings → OAuth2 → General". -4. Copiez le "Client ID" et ajoutez-le à votre `.env` en tant que `DISCORD_CLIENT_ID`. +4. Copiez le "Client ID" et ajoutez-le à votre `.env` en tant que `AUTH_DISCORD_ID`. 5. Cliquez sur "Reset Secret", copiez le nouveau secret et ajoutez-le à votre `.env` en tant que `DISCORD CLIENT_SECRET`. 6. Cliquez sur "Add Redirect" et saisissez `http://localhost:3000/api/auth/callback/discord`. - Pour le déploiement en production, suivez les étapes précédentes pour créer une autre application Discord, mais cette fois remplacez `http://localhost:3000` par l'URL vers laquelle vous déployez. diff --git a/www/src/pages/fr/usage/next-auth.mdx b/www/src/pages/fr/usage/next-auth.mdx index a26bf858c9..cb263a78f6 100644 --- a/www/src/pages/fr/usage/next-auth.mdx +++ b/www/src/pages/fr/usage/next-auth.mdx @@ -212,7 +212,7 @@ Ex.: 1. Rendez-vous dans [la section Applications du portail des développeurs Discord](https://discord.com/developers/applications), et cliquez sur "New Application" 1. Dans le menu des paramètres, allez dans "OAuth2 => General" -- Copiez l'ID client et collez-le dans `DISCORD_CLIENT_ID` dans `.env`. +- Copiez l'ID client et collez-le dans `AUTH_DISCORD_ID` dans `.env`. - Sous Client Secret, cliquez sur "Reset Secret" et copiez cette chaîne de caractères dans `DISCORD CLIENT_SECRET` dans `.env`. Soyez prudent car vous ne pourrez plus voir ce secret et le réinitialiser entraînera l'expiration du secret existant. - Cliquez sur "Add Redirect" et collez `/api/auth/callback/discord` (exemple pour le développement local : http://localhost:3000/api/auth/rappel/discord) - Enregistrez vos modifications diff --git a/www/src/pages/ja/usage/first-steps.md b/www/src/pages/ja/usage/first-steps.md index 852c02c0b1..70f9e847a8 100644 --- a/www/src/pages/ja/usage/first-steps.md +++ b/www/src/pages/ja/usage/first-steps.md @@ -20,8 +20,8 @@ lang: ja 1. Discord のアカウントが必要になりますので、まだの方は登録してください。 2. https://discord.com/developers/applications に移動し、右上の「New Application」をクリックします。アプリケーションの名前を付け、利用規約に同意してください。 3. アプリケーションの作成が完了したら、「Settings → OAuth2 → General」に移動してください。 -4. 「Client ID」をコピーし、`DISCORD_CLIENT_ID`として`.env`に追加します。 -5. 「Reset Secret」をクリックし、新しいシークレット情報をコピーし、`DISCORD_CLIENT_SECRET`として`.env`に追加します。 +4. 「Client ID」をコピーし、`AUTH_DISCORD_ID`として`.env`に追加します。 +5. 「Reset Secret」をクリックし、新しいシークレット情報をコピーし、`AUTH_DISCORD_SECRET`として`.env`に追加します。 6. 「Add Redirect」をクリックし、`http://localhost:3000/api/auth/callback/discord`と入力します。 - 本番環境でのデプロイの場合は、前述の手順で別の Discord アプリケーションを作成しますが、今回は`http://localhost:3000`をデプロイ先の URL で置き換えてください。 diff --git a/www/src/pages/ja/usage/next-auth.md b/www/src/pages/ja/usage/next-auth.md index 0932878cb4..5cc13c61df 100644 --- a/www/src/pages/ja/usage/next-auth.md +++ b/www/src/pages/ja/usage/next-auth.md @@ -181,8 +181,8 @@ NextAuth.js を Next.js ミドルウェアで利用する場合、認証に [JWT 1. [Discord Developer Portal の Application セクション](https://discord.com/developers/applications)に向かい「New Application」をクリックします。 2. 設定メニューの 「OAuth2 ⇒ General」に行きます -- Client ID をコピーして、`.env`の`DISCORD_CLIENT_ID`に貼り付けます。 -- Client Secret の下にある 「Reset Secret」をクリックし、その文字列を`.env`の`DISCORD_CLIENT_SECRET`にコピーしてください。このシークレット情報は二度と表示されないことと、リセットすると既存のシークレット情報は失効してしまうことについて注意してください。 +- Client ID をコピーして、`.env`の`AUTH_DISCORD_ID`に貼り付けます。 +- Client Secret の下にある 「Reset Secret」をクリックし、その文字列を`.env`の`AUTH_DISCORD_SECRET`にコピーしてください。このシークレット情報は二度と表示されないことと、リセットすると既存のシークレット情報は失効してしまうことについて注意してください。 - 「Add Redirect」をクリックし、`/api/auth/callback/discord` を貼り付ける(ローカル開発サーバの場合の例:http://localhost:3000/api/auth/callback/discord) - 変更を保存します - 開発用と本番用で同じ Discord Application を使用できますが、推奨はしません。また、開発時には[プロバイダをモックする](https://github.com/trpc/trpc/blob/main/examples/next-prisma-websockets-starter/src/pages/api/auth/%5B...nextauth%5D.ts)こと検討するのもよいでしょう。 diff --git a/www/src/pages/no/usage/first-steps.md b/www/src/pages/no/usage/first-steps.md index 2001dcee5d..a2dc4cd64c 100644 --- a/www/src/pages/no/usage/first-steps.md +++ b/www/src/pages/no/usage/first-steps.md @@ -20,8 +20,8 @@ Hvis du foretrekker en annen autentiseringsleverandør, kan du også bruke en av 1. Du trenger en Discord-konto. Meld deg på hvis du ikke har en ennå. 2. Naviger til https://discord.com/developers/applications og klikk "New Application" øverst til høyre. Gi applikasjonen din et navn og godta vilkårene for bruk. 3. Når applikasjonen din er opprettet, naviger til "Settings → OAuth2 → General". -4. Kopier "Client ID" og lim den inn i `.env` som `DISCORD_CLIENT_ID`. -5. Klikk "Reset Secret", kopier den nye hemmeligheten og lim inn verdien i `.env` som `DISCORD_CLIENT_SECRET`. +4. Kopier "Client ID" og lim den inn i `.env` som `AUTH_DISCORD_ID`. +5. Klikk "Reset Secret", kopier den nye hemmeligheten og lim inn verdien i `.env` som `AUTH_DISCORD_SECRET`. 6. Klikk "Add Redirect" og skriv inn `http://localhost:3000/api/auth/callback/discord`. - For utrulling i produksjonsmiljø må de foregående trinnene følges på nytt for å lage en annen Discord-applikasjon. Denne gangen erstatt `http://localhost:3000` med URL-en du publiserer til. 7. Lagre endringene. diff --git a/www/src/pages/no/usage/next-auth.md b/www/src/pages/no/usage/next-auth.md index f5f922aacf..a1deed32d7 100644 --- a/www/src/pages/no/usage/next-auth.md +++ b/www/src/pages/no/usage/next-auth.md @@ -179,8 +179,8 @@ Bruk av NextAuth.js med Next.js middleware [krever bruk av "JWT session strategy 2. Bytt til "OAuth2 => Generelt" i settings-menyen -- Kopier klient-ID-en og lim den inn i `DISCORD_CLIENT_ID` i `.env`. -- Under Client Secret, klikk på "Reset Secret" og kopier denne strengen til `DISCORD_CLIENT_SECRET` i `.env`. Vær forsiktig siden du ikke lenger vil kunne se denne hemmeligheten og tilbakestilling av den vil føre til at den eksisterende hemmeligheten utløper. +- Kopier klient-ID-en og lim den inn i `AUTH_DISCORD_ID` i `.env`. +- Under Client Secret, klikk på "Reset Secret" og kopier denne strengen til `AUTH_DISCORD_SECRET` i `.env`. Vær forsiktig siden du ikke lenger vil kunne se denne hemmeligheten og tilbakestilling av den vil føre til at den eksisterende hemmeligheten utløper. - Klikk på "Add Redirect" og lim inn `/api/auth/callback/discord` (eksempel for utvikling i lokal miljø: http://localhost:3000/api/auth/callback/discord) - Lagre endringene dine - Det er mulig, men ikke anbefalt, å bruke samme Discord-applikasjon for utvikling og produksjon. Du kan også vurdere å [Mocke leverandøren](https://github.com/trpc/trpc/blob/main/examples/next-prisma-websockets-starter/src/pages/api/auth/%5B...nextauth%5D.ts) under utviklingen. diff --git a/www/src/pages/pl/usage/first-steps.md b/www/src/pages/pl/usage/first-steps.md index d50fcec199..20ae6806d7 100644 --- a/www/src/pages/pl/usage/first-steps.md +++ b/www/src/pages/pl/usage/first-steps.md @@ -26,8 +26,8 @@ Oczywiście, jeżeli wolisz korzystać z innego, możesz użyć jednego z [wielu 1. Potrzebować będziesz konta Discord, więc utwórz je, jeśli jeszcze tego nie zrobiłeś. 2. Przejdź do strony https://discord.com/developers/applications i kliknij "New Appliction" w prawym górnym rogu. Nazwij ją i wyraź zgodę na warunki korzystania z serwisu. 3. Po stworzeniu aplikacji, przejdź do "Settings → OAuth2 → General". -4. Skopiuj "Client ID" i dodaj go do pliku `.env` pod kluczem `DISCORD_CLIENT_ID`. -5. Kliknij "Reset Secret", skopiuj nowy secret i dodaj go do pliku `.env` pod kluczem `DISCORD_CLIENT_SECRET`. +4. Skopiuj "Client ID" i dodaj go do pliku `.env` pod kluczem `AUTH_DISCORD_ID`. +5. Kliknij "Reset Secret", skopiuj nowy secret i dodaj go do pliku `.env` pod kluczem `AUTH_DISCORD_SECRET`. 6. Kliknij "Add Redirect" i wpisz `http://localhost:3000/api/auth/callback/discord`. - Dla deploymentu w wersji produkcyjnej, podążaj za powyższymi krokami aby stworzyć nową aplikację Discord, ale tym razem zamień `http://localhost:3000` na URL, na który wrzucasz swój projekt. diff --git a/www/src/pages/pl/usage/next-auth.md b/www/src/pages/pl/usage/next-auth.md index cde1f0212d..d4a65135f3 100644 --- a/www/src/pages/pl/usage/next-auth.md +++ b/www/src/pages/pl/usage/next-auth.md @@ -178,8 +178,8 @@ Wykorzystanie middleware'a Next.js [wymaga od Ciebie skorzystania ze strategii J 1. Przejdź do [sekcji Aplikacje w Panelu Discord Developer Portal](https://discord.com/developers/applications), a następnie kliknij na "New Application" 2. W menu ustawień, przejdź do "OAuth2 => General" -- Skopiuj Client ID i wklej go do pliku `.env` pod kluczem `DISCORD_CLIENT_ID`. -- Pod Client Secret, kliknij "Reset Secret" i skopiuj podany tekst do pliku `.env` pod kluczem `DISCORD_CLIENT_SECRET`. Uważaj - nie będziesz mógł ponownie zobaczyć tego klucza, a jego reset spowoduje wygaśnięcie aktualnego. +- Skopiuj Client ID i wklej go do pliku `.env` pod kluczem `AUTH_DISCORD_ID`. +- Pod Client Secret, kliknij "Reset Secret" i skopiuj podany tekst do pliku `.env` pod kluczem `AUTH_DISCORD_SECRET`. Uważaj - nie będziesz mógł ponownie zobaczyć tego klucza, a jego reset spowoduje wygaśnięcie aktualnego. - Dodaj "Add Redirect" i wklej tam `/api/auth/callback/discord` (przykładowo dla lokalnej aplikacji: http://localhost:3000/api/auth/callback/discord) - Zapisz zmiany - Jest możliwość (nie jest ona jednak polecana), aby wykorzystać tą samą aplikację Discorda dla zarówno aplikacji lokalnej i tej w wersji produkcyjnej. Możesz także wykorzystać [mockowanie providera](https://github.com/trpc/trpc/blob/next/examples/next-prisma-starter-websockets/src/pages/api/auth/%5B...nextauth%5D.ts) podczas rozwoju aplikacji. diff --git a/www/src/pages/pt/usage/first-steps.md b/www/src/pages/pt/usage/first-steps.md index dd641582cd..f39b8fc7e7 100644 --- a/www/src/pages/pt/usage/first-steps.md +++ b/www/src/pages/pt/usage/first-steps.md @@ -20,8 +20,8 @@ Claro, se você preferir usar um provedor de autenticação diferente, também p 1. Você precisará de uma conta no Discord, então crie uma se ainda não tiver. 2. Navegue até https://discord.com/developers/applications e clique em "Novo aplicativo" no canto superior direito. Dê um nome ao seu aplicativo e concorde com os Termos de Serviço. 3. Depois de criar seu aplicativo, navegue até "Configurações → OAuth2 → Geral". -4. Copie o "ID do cliente" e adicione-o ao seu `.env` como `DISCORD_CLIENT_ID`. -5. Clique em "Redefinir Segredo", copie o novo segredo e adicione-o ao seu `.env` como `DISCORD_CLIENT_SECRET`. +4. Copie o "ID do cliente" e adicione-o ao seu `.env` como `AUTH_DISCORD_ID`. +5. Clique em "Redefinir Segredo", copie o novo segredo e adicione-o ao seu `.env` como `AUTH_DISCORD_SECRET`. 6. Clique em "Adicionar redirecionamento" e digite `http://localhost:3000/api/auth/callback/discord`. - Para implantação de produção, siga as etapas anteriores para criar outro aplicativo Discord, mas desta vez substitua `http://localhost:3000` pela URL na qual você está implantando. 7. Salve as alterações. diff --git a/www/src/pages/pt/usage/next-auth.md b/www/src/pages/pt/usage/next-auth.md index 074ff4edf5..8c68589e43 100644 --- a/www/src/pages/pt/usage/next-auth.md +++ b/www/src/pages/pt/usage/next-auth.md @@ -181,8 +181,8 @@ Uso de NextAuth.js com middleware Next.js [requer o uso da estratégia de sessã 1. Vá para [a seção Aplicativos no Portal do desenvolvedor do Discord](https://discord.com/developers/applications) e clique em "Novo aplicativo" 2. No menu de configurações, vá para "OAuth2 => Geral" -- Copie o Client ID e cole-o em `DISCORD_CLIENT_ID` em `.env`. -- Em Client Secret, clique em "Reset Secret" e copie essa string para `DISCORD_CLIENT_SECRET` em `.env`. Tenha cuidado, pois você não poderá ver esse segredo novamente e redefini-lo fará com que o existente expire. +- Copie o Client ID e cole-o em `AUTH_DISCORD_ID` em `.env`. +- Em Client Secret, clique em "Reset Secret" e copie essa string para `AUTH_DISCORD_SECRET` em `.env`. Tenha cuidado, pois você não poderá ver esse segredo novamente e redefini-lo fará com que o existente expire. - Clique em "Add Redirect" e cole em `/api/auth/callback/discord` (exemplo para desenvolvimento local: http://localhost:3000/api/auth/callback/discord) - Salve suas alterações - É possível, mas não recomendado, usar o mesmo aplicativo Discord tanto para desenvolvimento quanto para produção. Você também pode considerar [mockar o Provider](https://github.com/trpc/trpc/blob/next/examples/next-prisma-starter-websockets/src/pages/api/auth/%5B...nextauth%5D.ts) durante o desenvolvimento. diff --git a/www/src/pages/ru/usage/first-steps.md b/www/src/pages/ru/usage/first-steps.md index ef4d40c15c..5bdd64d1ea 100644 --- a/www/src/pages/ru/usage/first-steps.md +++ b/www/src/pages/ru/usage/first-steps.md @@ -20,8 +20,8 @@ lang: ru 1. Вам нужен аккаунт Discord, поэтому зарегистрируйтесь, если еще не зарегистрировались. 2. Перейдите на https://discord.com/developers/applications и нажмите «New Application» в правом верхнем углу. Дайте вашему приложению имя и согласитесь с Условиями использования. 3. Когда вы создадите приложение, перейдите к «Settings → OAuth2 → General». -4. Скопируйте «Client ID» и добавьте его в ваш `.env` как `DISCORD_CLIENT_ID`. -5. Нажмите «Reset Secret», скопируйте новый секрет и добавьте его в ваш `.env` как `DISCORD_CLIENT_SECRET`. +4. Скопируйте «Client ID» и добавьте его в ваш `.env` как `AUTH_DISCORD_ID`. +5. Нажмите «Reset Secret», скопируйте новый секрет и добавьте его в ваш `.env` как `AUTH_DISCORD_SECRET`. 6. Нажмите «Add Redirect» и введите `http://localhost:3000/api/auth/callback/discord`. - Для развертывания в продакшене следуйте предыдущим шагам для создания другого приложения Discord, но на этот раз замените `http://localhost:3000` на URL, на который вы развертываете. 7. Сохраните изменения. diff --git a/www/src/pages/ru/usage/next-auth.md b/www/src/pages/ru/usage/next-auth.md index 98f82d79b0..f6c19e5bd1 100644 --- a/www/src/pages/ru/usage/next-auth.md +++ b/www/src/pages/ru/usage/next-auth.md @@ -181,8 +181,8 @@ const userRouter = router({ 1. Перейдите в [раздел Applications в Discord Developer Portal](https://discord.com/developers/applications), и нажмите на "New Application" 2. В меню настроек перейдите к "OAuth2 => General" -- Скопируйте Client ID и вставьте его в `DISCORD_CLIENT_ID` в `.env`. -- Возле Client Secret нажмите "Reset Secret" и скопируйте эту строку в `DISCORD_CLIENT_SECRET` в `.env`. Будьте осторожны, поскольку вы больше не сможете увидеть этот секрет, и сброс его приведет к тому, что существующий истечет. +- Скопируйте Client ID и вставьте его в `AUTH_DISCORD_ID` в `.env`. +- Возле Client Secret нажмите "Reset Secret" и скопируйте эту строку в `AUTH_DISCORD_SECRET` в `.env`. Будьте осторожны, поскольку вы больше не сможете увидеть этот секрет, и сброс его приведет к тому, что существующий истечет. - Нажмите "Add Redirect" и вставьте `/api/auth/callback/discord` (пример для локальной разработки: http://localhost:3000/api/auth/callback/discord) - Сохраните изменения - Возможно, но не рекомендуется, использовать одно и то же приложение Discord для разработки и продакшена. Вы также можете рассмотреть [Mocking the Provider](https://github.com/trpc/trpc/blob/next/examples/next-prisma-starter-websockets/src/pages/api/auth/%5B...nextauth%5D.ts) во время разработки. diff --git a/www/src/pages/uk/usage/first-steps.md b/www/src/pages/uk/usage/first-steps.md index c9e1b984b6..79c1cd90be 100644 --- a/www/src/pages/uk/usage/first-steps.md +++ b/www/src/pages/uk/usage/first-steps.md @@ -30,8 +30,8 @@ lang: uk 1. Вам потрібен обліковий запис Discord, тому зареєструйтеся, якщо ще не зареєструвалися. 2. Перейдіть на https://discord.com/developers/applications і натисніть "New Application" у правому верхньому куті. Дайте вашому додатку ім'я та погодьтеся з Умовами використання. 3. Коли ви створите додаток, перейдіть до "Settings → OAuth2 → General". -4. Скопіюйте "Client ID" і додайте його у ваш `.env` як `DISCORD_CLIENT_ID`. -5. Натисніть "Reset Secret", скопіюйте новий secret і додайте його у ваш `.env` як `DISCORD_CLIENT_SECRET`. +4. Скопіюйте "Client ID" і додайте його у ваш `.env` як `AUTH_DISCORD_ID`. +5. Натисніть "Reset Secret", скопіюйте новий secret і додайте його у ваш `.env` як `AUTH_DISCORD_SECRET`. 6. Натисніть "Add Redirect" і введіть `http://localhost:3000/api/auth/callback/discord`. - Для деплойменту в продакшені дотримуйтесь попередніх кроків для створення іншого додатка Discord, але цього разу замініть `http://localhost:3000` на URL, на який ви деплоїте. 7. Збережіть зміни. diff --git a/www/src/pages/uk/usage/next-auth.mdx b/www/src/pages/uk/usage/next-auth.mdx index 908a82c9d8..c311d37b2a 100644 --- a/www/src/pages/uk/usage/next-auth.mdx +++ b/www/src/pages/uk/usage/next-auth.mdx @@ -215,8 +215,8 @@ const userRouter = router({ 1. Перейдіть до розділу Applications у [Discord Developer Portal](https://discord.com/developers/applications) і натисніть "New Application" 2. У меню налаштувань перейдіть до "OAuth2 => General" -- Скопіюйте Client ID і вставте його в `DISCORD_CLIENT_ID` у `.env`. -- Біля Client Secret натисніть "Reset Secret" і скопіюйте цей рядок у `DISCORD_CLIENT_SECRET` у `.env`. Будьте обережними, оскільки ви більше не зможете побачити цей secret, і скидання його призведе до того, що існуючий протермінується. +- Скопіюйте Client ID і вставте його в `AUTH_DISCORD_ID` у `.env`. +- Біля Client Secret натисніть "Reset Secret" і скопіюйте цей рядок у `AUTH_DISCORD_SECRET` у `.env`. Будьте обережними, оскільки ви більше не зможете побачити цей secret, і скидання його призведе до того, що існуючий протермінується. - Натисніть "Add Redirect" і вставте `/api/auth/callback/discord` (приклад для локальної розробки: http://localhost:3000/api/auth/callback/discord) - Збережіть зміни - Можливо, але не рекомендується, використовувати один і той же додаток Discord для розробки та продакшену. Ви також можете розглянути [Mocking the Provider](https://github.com/trpc/trpc/blob/main/examples/next-prisma-websockets-starter/src/pages/api/auth/%5B...nextauth%5D.ts) під час розробки. diff --git a/www/src/pages/zh-hans/usage/first-steps.md b/www/src/pages/zh-hans/usage/first-steps.md index 0b8e1dbe38..dad62c15cc 100644 --- a/www/src/pages/zh-hans/usage/first-steps.md +++ b/www/src/pages/zh-hans/usage/first-steps.md @@ -24,8 +24,8 @@ lang: zh-hans 1. 你将需要一个 Discord 账号,所以如果你没有,请先注册一个。 2. 前往 然后在右上角点击 "New Application"。给你的应用创建一个名称,并同意相关的服务条款。 3. 当你的应用被创建后,前往 "Settings → OAuth2 → General"。 -4. 复制 "Client ID" 然后作为 `DISCORD_CLIENT_ID` 添加到 `.env`。 -5. 点击 "Reset Secret",复制新的密钥,然后作为 `DISCORD_CLIENT_SECRET` 添加到 `.env`。 +4. 复制 "Client ID" 然后作为 `AUTH_DISCORD_ID` 添加到 `.env`。 +5. 点击 "Reset Secret",复制新的密钥,然后作为 `AUTH_DISCORD_SECRET` 添加到 `.env`。 6. 点击 "Add Redirect",然后输入 `http://localhost:3000/api/auth/callback/discord`。 - 对于生产环境的部署,按照之前的步骤来创建另一个 Discord 应用,但是这一次将链接 `http://localhost:3000` 替换为实际生产环境的链接。 7. 保存你的更改。 diff --git a/www/src/pages/zh-hans/usage/next-auth.mdx b/www/src/pages/zh-hans/usage/next-auth.mdx index 6b82a4eaec..c17c4d21bc 100644 --- a/www/src/pages/zh-hans/usage/next-auth.mdx +++ b/www/src/pages/zh-hans/usage/next-auth.mdx @@ -212,8 +212,8 @@ const userRouter = router({ 1. 前往 [Discord 开发者页面的应用部分](https://discord.com/developers/applications),然后点击 "New Application" 2. 在设置菜单中,依次前往 "OAuth2 => General" -- 复制 Client ID,然后粘贴到 `.env` 文件中的 `DISCORD_CLIENT_ID`。 -- 在 Client Secret 下方,点击 "Reset Secret",然后复制该字符串到 `env` 中的 `DISCORD_CLIENT_SECRET`。务必要细心,因为你无法再次查看该密钥了,而将它重置会让现存的密钥失效。 +- 复制 Client ID,然后粘贴到 `.env` 文件中的 `AUTH_DISCORD_ID`。 +- 在 Client Secret 下方,点击 "Reset Secret",然后复制该字符串到 `env` 中的 `AUTH_DISCORD_SECRET`。务必要细心,因为你无法再次查看该密钥了,而将它重置会让现存的密钥失效。 - 点击 "Add Redirect",然后将你应用的网址替换 `/api/auth/callback/discord` 里的 ``(例如,一个开发阶段的完整链接像这样:http://localhost:3000/api/auth/callback/discord) - 保存你的更改 - 在开发和生产环境使用同一个 Discord 应用是可行的,但不鼓励这么做。你应该也考虑在开发阶段 [模拟认证服务](https://github.com/trpc/trpc/blob/main/examples/next-prisma-websockets-starter/src/pages/api/auth/%5B...nextauth%5D.ts)。 From fd1af0280b71c276460556ee313783a2f7d5c1f1 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sat, 26 Oct 2024 12:58:46 +0200 Subject: [PATCH 13/16] Update grumpy-otters-kneel.md --- .changeset/grumpy-otters-kneel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/grumpy-otters-kneel.md b/.changeset/grumpy-otters-kneel.md index 464df113c7..0c34bb11e0 100644 --- a/.changeset/grumpy-otters-kneel.md +++ b/.changeset/grumpy-otters-kneel.md @@ -2,4 +2,4 @@ "create-t3-app": minor --- -update to next.js 15 +update to next.js 15 and next-auth v5 From 826d8149c4bc0540c738fb4d4ab18b0c2f2e647d Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 26 Oct 2024 13:05:42 +0200 Subject: [PATCH 14/16] use turbo --- cli/template/base/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/template/base/package.json b/cli/template/base/package.json index 85dab873ef..556018138c 100644 --- a/cli/template/base/package.json +++ b/cli/template/base/package.json @@ -4,7 +4,7 @@ "type": "module", "private": true, "scripts": { - "dev": "next dev", + "dev": "next dev --turbo", "build": "next build", "start": "next start", "lint": "next lint", From 3a4252d4cf0d9bb9134911175d011a7b6a6dc795 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 26 Oct 2024 13:11:51 +0200 Subject: [PATCH 15/16] log need for discord credentials --- cli/src/helpers/logNextSteps.ts | 6 ++++++ www/src/pages/en/usage/first-steps.md | 1 - www/src/pages/es/usage/first-steps.md | 1 - www/src/pages/fr/usage/first-steps.md | 1 - www/src/pages/ja/usage/first-steps.md | 1 - www/src/pages/no/usage/first-steps.md | 1 - www/src/pages/pt/usage/first-steps.md | 1 - www/src/pages/ru/usage/first-steps.md | 1 - www/src/pages/uk/usage/first-steps.md | 1 - www/src/pages/zh-hans/usage/first-steps.md | 1 - 10 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cli/src/helpers/logNextSteps.ts b/cli/src/helpers/logNextSteps.ts index 88629fc1b4..9ba296b55d 100644 --- a/cli/src/helpers/logNextSteps.ts +++ b/cli/src/helpers/logNextSteps.ts @@ -47,6 +47,12 @@ export const logNextSteps = async ({ } } + if (packages?.nextAuth.inUse) { + logger.info( + ` Fill in your .env with necessary values. See https://create.t3.gg/en/usage/first-steps for more info.` + ); + } + if (["npm", "bun"].includes(pkgManager)) { logger.info(` ${pkgManager} run dev`); } else { diff --git a/www/src/pages/en/usage/first-steps.md b/www/src/pages/en/usage/first-steps.md index 6f7af9b0c2..a90b52c600 100644 --- a/www/src/pages/en/usage/first-steps.md +++ b/www/src/pages/en/usage/first-steps.md @@ -35,7 +35,6 @@ Of course, if you prefer to use a different auth provider, you can also use one 6. Click "Add Redirect" and type in `http://localhost:3000/api/auth/callback/discord`. - For production deployment, follow the previous steps to create another Discord Application, but this time replace `http://localhost:3000` with the URL that you are deploying to. 7. Save Changes. -8. Set the `AUTH_SECRET` in `.env`. In development any string will work, for production see the note in `.env` on generating a secure secret. You should now be able to log in. diff --git a/www/src/pages/es/usage/first-steps.md b/www/src/pages/es/usage/first-steps.md index 8e91fe7b3e..a49b71219b 100644 --- a/www/src/pages/es/usage/first-steps.md +++ b/www/src/pages/es/usage/first-steps.md @@ -25,7 +25,6 @@ Por supuesto, si prefieres usar un proveedor de autenticación diferente, tambi 6. Haz clic en "Add Redirect" y escribe `http://localhost:3000/api/auth/callback/discord`. - Para la implementación de producción, sigue los pasos anteriores para crear otra aplicación Discord, pero esta vez reemplaza `http://localhost:3000` con la URL de producción en la que está implementando. 7. Guarda los cambios. -8. Configura `AUTH_SECRET` en `.env`. En desarrollo, cualquier cadena funcionará, para producción, consulta la nota de `.env` sobre la generación de un secreto seguro. Ahora deberías poder iniciar sesión. diff --git a/www/src/pages/fr/usage/first-steps.md b/www/src/pages/fr/usage/first-steps.md index d1d105a44d..34202c35af 100644 --- a/www/src/pages/fr/usage/first-steps.md +++ b/www/src/pages/fr/usage/first-steps.md @@ -26,7 +26,6 @@ Bien sûr, si vous préférez utiliser un autre fournisseur d'authentification, 6. Cliquez sur "Add Redirect" et saisissez `http://localhost:3000/api/auth/callback/discord`. - Pour le déploiement en production, suivez les étapes précédentes pour créer une autre application Discord, mais cette fois remplacez `http://localhost:3000` par l'URL vers laquelle vous déployez. 7. Sauvegarder les modifications. -8. Définissez `AUTH_SECRET` dans `.env`. En développement, n'importe quelle chaîne fonctionnera, pour la production, voir la note dans `.env` sur la génération d'un secret sécurisé. Vous devriez maintenant pouvoir vous connecter. diff --git a/www/src/pages/ja/usage/first-steps.md b/www/src/pages/ja/usage/first-steps.md index 70f9e847a8..e0563e2734 100644 --- a/www/src/pages/ja/usage/first-steps.md +++ b/www/src/pages/ja/usage/first-steps.md @@ -27,7 +27,6 @@ lang: ja - 本番環境でのデプロイの場合は、前述の手順で別の Discord アプリケーションを作成しますが、今回は`http://localhost:3000`をデプロイ先の URL で置き換えてください。 7. 変更を保存します。 -8. `.env`に`AUTH_SECRET`を設定します。開発環境では任意の文字列が機能しますが、本番環境では`.env`内のセキュアなシークレット情報の生成に関する注意事項を参照してください。 これでログインできるようになります。 diff --git a/www/src/pages/no/usage/first-steps.md b/www/src/pages/no/usage/first-steps.md index a2dc4cd64c..c7fbd7eb0d 100644 --- a/www/src/pages/no/usage/first-steps.md +++ b/www/src/pages/no/usage/first-steps.md @@ -25,7 +25,6 @@ Hvis du foretrekker en annen autentiseringsleverandør, kan du også bruke en av 6. Klikk "Add Redirect" og skriv inn `http://localhost:3000/api/auth/callback/discord`. - For utrulling i produksjonsmiljø må de foregående trinnene følges på nytt for å lage en annen Discord-applikasjon. Denne gangen erstatt `http://localhost:3000` med URL-en du publiserer til. 7. Lagre endringene. -8. Skriv `AUTH_SECRET` i `.env`. Hvilken som helst streng vil fungere under utviklingen. For bruk i produksjonsmiljø, ta en titt på notatet i `.env` for å lage en sikker hemmelighetvariabel. Du skal nå kunne logge på. diff --git a/www/src/pages/pt/usage/first-steps.md b/www/src/pages/pt/usage/first-steps.md index f39b8fc7e7..e20170e0bf 100644 --- a/www/src/pages/pt/usage/first-steps.md +++ b/www/src/pages/pt/usage/first-steps.md @@ -25,7 +25,6 @@ Claro, se você preferir usar um provedor de autenticação diferente, também p 6. Clique em "Adicionar redirecionamento" e digite `http://localhost:3000/api/auth/callback/discord`. - Para implantação de produção, siga as etapas anteriores para criar outro aplicativo Discord, mas desta vez substitua `http://localhost:3000` pela URL na qual você está implantando. 7. Salve as alterações. -8. Defina `AUTH_SECRET` em `.env`. Em desenvolvimento, qualquer string funcionará, para produção, veja a nota em `.env` sobre como gerar um segredo seguro. Agora você deve conseguir fazer login. diff --git a/www/src/pages/ru/usage/first-steps.md b/www/src/pages/ru/usage/first-steps.md index 5bdd64d1ea..059c2bee3f 100644 --- a/www/src/pages/ru/usage/first-steps.md +++ b/www/src/pages/ru/usage/first-steps.md @@ -25,7 +25,6 @@ lang: ru 6. Нажмите «Add Redirect» и введите `http://localhost:3000/api/auth/callback/discord`. - Для развертывания в продакшене следуйте предыдущим шагам для создания другого приложения Discord, но на этот раз замените `http://localhost:3000` на URL, на который вы развертываете. 7. Сохраните изменения. -8. Установите `AUTH_SECRET` в `.env`. В разработке любая строка будет работать, для продакшена см. Примечание в `.env` о генерации безопасного секрета. Теперь у вас должна быть возможность войти в систему. diff --git a/www/src/pages/uk/usage/first-steps.md b/www/src/pages/uk/usage/first-steps.md index 79c1cd90be..710028fb77 100644 --- a/www/src/pages/uk/usage/first-steps.md +++ b/www/src/pages/uk/usage/first-steps.md @@ -35,7 +35,6 @@ lang: uk 6. Натисніть "Add Redirect" і введіть `http://localhost:3000/api/auth/callback/discord`. - Для деплойменту в продакшені дотримуйтесь попередніх кроків для створення іншого додатка Discord, але цього разу замініть `http://localhost:3000` на URL, на який ви деплоїте. 7. Збережіть зміни. -8. Встановіть `AUTH_SECRET` у `.env`. У розробці будь-який рядок працюватиме, для продакшена див. примітка в `.env` про генерацію безпечного secret. Тепер у вас має бути можливість увійти в систему. diff --git a/www/src/pages/zh-hans/usage/first-steps.md b/www/src/pages/zh-hans/usage/first-steps.md index dad62c15cc..29c7bf4f0f 100644 --- a/www/src/pages/zh-hans/usage/first-steps.md +++ b/www/src/pages/zh-hans/usage/first-steps.md @@ -29,7 +29,6 @@ lang: zh-hans 6. 点击 "Add Redirect",然后输入 `http://localhost:3000/api/auth/callback/discord`。 - 对于生产环境的部署,按照之前的步骤来创建另一个 Discord 应用,但是这一次将链接 `http://localhost:3000` 替换为实际生产环境的链接。 7. 保存你的更改。 -8. 在 `.env` 中设置 `AUTH_SECRET`。在开发过程中,任何字符串都能起效,但对于生产环境,记得查看 `.env` 文件中关于生成安全密钥的注释。 你现在应该可以登入到你的应用中了。 From 1e0aa940900e3f519984d4da03b1aa3ce57ea3de Mon Sep 17 00:00:00 2001 From: Matvey Ryabchikov <35634442+ronanru@users.noreply.github.com> Date: Sat, 26 Oct 2024 17:52:59 +0300 Subject: [PATCH 16/16] bump eslint-config-next version --- cli/template/base/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/template/base/package.json b/cli/template/base/package.json index 556018138c..00ca211bdc 100644 --- a/cli/template/base/package.json +++ b/cli/template/base/package.json @@ -16,7 +16,7 @@ "dependencies": { "@t3-oss/env-nextjs": "^0.10.1", "geist": "^1.3.0", - "next": "^15.0.0", + "next": "^15.0.1", "react": "^18.3.1", "react-dom": "^18.3.1", "zod": "^3.23.3" @@ -29,7 +29,7 @@ "@typescript-eslint/eslint-plugin": "^8.1.0", "@typescript-eslint/parser": "^8.1.0", "eslint": "^8.57.0", - "eslint-config-next": "^14.2.4", + "eslint-config-next": "^15.0.1", "typescript": "^5.5.3" } }