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` 文件中关于生成安全密钥的注释。 你现在应该可以登入到你的应用中了。