ceespert
ceespert
TTCTheo's Typesafe Cult
Created by ceespert on 6/8/2023 in #questions
Why does NPM try to log in?
NPM keeps trying to log in when I run my pipeline, but I do not know why. My project is located in a private repository from a GitHub organization (I'm the CEO and the janitor at the same time). This is my package.json: ` { "name": "website", "version": "0.1.0", "private": true, "scripts": { "build": "next build", "dev": "next dev", "postinstall": "prisma generate", "lint": "next lint", "start": "next start", "prepare": "husky install", "test:e2e": "playwright test", "test": "jest --watch" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.4.0", "@fortawesome/free-brands-svg-icons": "^6.4.0", "@fortawesome/free-regular-svg-icons": "^6.4.0", "@fortawesome/free-solid-svg-icons": "^6.4.0", "@fortawesome/react-fontawesome": "^0.2.0", "@next-auth/prisma-adapter": "^1.0.5", "@prisma/client": "^4.11.0", "@tanstack/react-query": "^4.28.0", "@trpc/client": "^10.18.0", "@trpc/next": "^10.18.0", "@trpc/react-query": "^10.18.0", "@trpc/server": "^10.18.0", "daisyui": "^2.51.5", "next": "^13.2.4", "next-auth": "^4.21.0", "prettier": "^2.8.7", "react": "18.2.0", "react-dom": "18.2.0", "react-select": "^5.7.2", "superjson": "1.12.2", "zod": "^3.21.4" }, "devDependencies": { "@playwright/test": "^1.34.3", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", "@types/eslint": "^8.21.3", "@types/node": "^18.15.5", "@types/react": "^18.0.28", "@types/react-dom": "^18.0.11", "@typescript-eslint/eslint-plugin": "^5.56.0", "@typescript-eslint/parser": "^5.56.0", "autoprefixer": "^10.4.14", "eslint": "^8.36.0", "eslint-config-next": "^13.2.4", "eslint-config-prettier": "^8.8.0", "husky": "^8.0.3", "postcss": "^8.4.23", "prisma": "^4.11.0", "tailwindcss": "^3.3.1", "typescript": "^5.0.2" }, ... }
12 replies
TTCTheo's Typesafe Cult
Created by ceespert on 5/15/2023 in #questions
Keep getting "NEXTAUTH_URL: [ 'String must contain at least 1 character(s)' ]"
I'm building a deployment workflow and I keep getting this error. The documentation states that setting this variable is unnecessary when deploying to Vercel, which is what I'm trying to do. Both setting and not setting the variable are things that I have tried. This is my 'env.mjs' file
import { z } from "zod";

const server = z.object({
DATABASE_URL: z.string().url(),
NODE_ENV: z.enum(["development", "test", "production"]),
NEXTAUTH_SECRET:
process.env.NODE_ENV === "production"
? z.string().min(1)
: z.string().min(1).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().min(1) : z.string().url(),
),
GOOGLE_CLIENT_ID: z.string(),
GOOGLE_CLIENT_SECRET: z.string(),
});

const client = z.object(
/** @satisfies {Record<`NEXT_PUBLIC_${string}`, import('zod').ZodType>} */ (
{
// NEXT_PUBLIC_CLIENTVAR: z.string().min(1),
}
),
);

const processEnv = {
DATABASE_URL: process.env.DATABASE_URL,
NODE_ENV: process.env.NODE_ENV,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
};
import { z } from "zod";

const server = z.object({
DATABASE_URL: z.string().url(),
NODE_ENV: z.enum(["development", "test", "production"]),
NEXTAUTH_SECRET:
process.env.NODE_ENV === "production"
? z.string().min(1)
: z.string().min(1).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().min(1) : z.string().url(),
),
GOOGLE_CLIENT_ID: z.string(),
GOOGLE_CLIENT_SECRET: z.string(),
});

const client = z.object(
/** @satisfies {Record<`NEXT_PUBLIC_${string}`, import('zod').ZodType>} */ (
{
// NEXT_PUBLIC_CLIENTVAR: z.string().min(1),
}
),
);

const processEnv = {
DATABASE_URL: process.env.DATABASE_URL,
NODE_ENV: process.env.NODE_ENV,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
};
I only changed the provider to Google, but there is a slight chance that I destroyed it.
4 replies