From 26d159c9895e3b3684163758639795e2219f6f0b Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Thu, 20 Nov 2025 15:35:33 -0300 Subject: [PATCH 1/6] varlock init - convert .env.example to .env.schema --- .env.example | 29 --------------- .env.schema | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 103 insertions(+), 29 deletions(-) delete mode 100644 .env.example create mode 100644 .env.schema diff --git a/.env.example b/.env.example deleted file mode 100644 index c5daeb2..0000000 --- a/.env.example +++ /dev/null @@ -1,29 +0,0 @@ -LITEFS_DIR="/litefs/data" -DATABASE_PATH="./prisma/data.db" -DATABASE_URL="file:./data.db?connection_limit=1" -CACHE_DATABASE_PATH="./other/cache.db" -SESSION_SECRET="super-duper-s3cret" -HONEYPOT_SECRET="super-duper-s3cret" -RESEND_API_KEY="re_blAh_blaHBlaHblahBLAhBlAh" -SENTRY_DSN="your-dsn" - -# this is set to a random value in the Dockerfile -INTERNAL_COMMAND_TOKEN="some-made-up-token" - -# the mocks and some code rely on these two being prefixed with "MOCK_" -# if they aren't then the real github api will be attempted -GITHUB_CLIENT_ID="MOCK_GITHUB_CLIENT_ID" -GITHUB_CLIENT_SECRET="MOCK_GITHUB_CLIENT_SECRET" -GITHUB_TOKEN="MOCK_GITHUB_TOKEN" -GITHUB_REDIRECT_URI="https://example.com/auth/github/callback" - -# set this to false to prevent search engines from indexing the website -# default to allow indexing for seo safety -ALLOW_INDEXING="true" - -# Tigris Object Storage (S3-compatible) Configuration -AWS_ACCESS_KEY_ID="mock-access-key" -AWS_SECRET_ACCESS_KEY="mock-secret-key" -AWS_REGION="auto" -AWS_ENDPOINT_URL_S3="https://fly.storage.tigris.dev" -BUCKET_NAME="mock-bucket" diff --git a/.env.schema b/.env.schema new file mode 100644 index 0000000..5f242dc --- /dev/null +++ b/.env.schema @@ -0,0 +1,102 @@ +# This env file uses @env-spec - see https://varlock.dev/env-spec for more info +# +# @defaultRequired=true @defaultSensitive=false +# @currentEnv=$NODE_ENV +# @generateTypes(lang=ts, path=types/env-vars.d.ts) +# ---------- + +# @type=enum(development, production, test) +NODE_ENV=development +# @type=enum(development, production, test) +MODE=$NODE_ENV + +# @type=port +PORT=3000 + +LITEFS_DIR="/litefs/data" +DATABASE_PATH="./prisma/data.db" +DATABASE_URL="file:./data.db?connection_limit=1" +CACHE_DATABASE_PATH="./other/cache.db" + +# used to secure sessions +# @sensitive +# @docs(https://stack-staging.epicweb.dev/topic/deployment) +SESSION_SECRET="super-duper-s3cret" + +# encryption seed for honeypot server +# @sensitive +# @docs(https://stack-staging.epicweb.dev/topic/deployment) +HONEYPOT_SECRET="super-duper-s3cret" + +# this is set to a random value in the Dockerfile +# @sensitive +INTERNAL_COMMAND_TOKEN="some-made-up-token" + +# set to false to prevent search engines from indexing the website (defaults to allow) +ALLOW_INDEXING=true + +# enables mocks for external services +MOCKS=forEnv(development, test) + +# will be set to curent commit sha in deployments +# @optional +COMMIT_SHA= + +# API key for Resend (email service) +# @type=string(startsWith=re_) +# @sensitive +# @optional # remove this if using resend +# @docs(https://resend.com/docs/dashboard/api-keys/introduction#what-is-an-api-key) +RESEND_API_KEY= + +# will be set to true when running in CI +CI=false + +# Sentry settings (error tracking) +# note that SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_PROJECT are optional +# but enable @sentry/react-router integration and release tagging +# --- +# @type=url +# @optional # remove this if using sentry +# @example=https://examplePublicKey@o0.ingest.sentry.io/0 +# @docs(https://docs.sentry.io/concepts/key-terms/dsn-explainer/) +SENTRY_DSN= +# @optional @sensitive +SENTRY_AUTH_TOKEN= +# @required=if($SENTRY_AUTH_TOKEN) +SENTRY_ORG= +# @required=if($SENTRY_AUTH_TOKEN) +SENTRY_PROJECT= + +# GitHub settings +# +# the mocks and some code rely on these being prefixed with "MOCK_" +# if they aren't then the real github api will be attempted +# --- +GITHUB_CLIENT_ID="MOCK_GITHUB_CLIENT_ID" +# @sensitive +GITHUB_CLIENT_SECRET="MOCK_GITHUB_CLIENT_SECRET" +# @sensitive +GITHUB_TOKEN="MOCK_GITHUB_TOKEN" +# @type=url +GITHUB_REDIRECT_URI="https://example.com/auth/github/callback" + + +# Tigris Object Storage (S3-compatible) Configuration +# --- +AWS_ACCESS_KEY_ID="mock-access-key" +# @sensitive +AWS_SECRET_ACCESS_KEY="mock-secret-key" +AWS_REGION="auto" +# @type=url +AWS_ENDPOINT_URL_S3="https://fly.storage.tigris.dev" +BUCKET_NAME="mock-bucket" + +# Populated by fly.io +# --- +# current fly.io region +# @optional +FLY_REGION= +# app name as set in fly.io +# @optional +FLY_APP_NAME= \ No newline at end of file diff --git a/package.json b/package.json index 6a1f4c8..a673cf7 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "spin-delay": "^2.0.1", "tailwind-merge": "^3.2.0", "tailwindcss": "^4.1.5", + "varlock": "^0.1.2", "vite-env-only": "^3.0.3", "zod": "^3.24.4" }, From 9d7a2bc19b39fb2d044bcd3ad4ced204201c4d2e Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Thu, 20 Nov 2025 15:35:53 -0300 Subject: [PATCH 2/6] swap dotenv for varlock --- .gitignore | 3 ++ .prettierignore | 2 ++ .vscode/extensions.json | 3 +- eslint.config.js | 5 ++- index.js | 2 +- other/Dockerfile | 2 +- package-lock.json | 68 +++++++++++++++++++++++++++++------ package.json | 5 ++- playwright.config.ts | 2 +- prisma.config.ts | 8 +++++ tests/setup/global-setup.ts | 2 +- tests/setup/setup-test-env.ts | 2 +- 12 files changed, 84 insertions(+), 20 deletions(-) create mode 100644 prisma.config.ts diff --git a/.gitignore b/.gitignore index 2345034..ef74da5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ node_modules /build /server-build .env +.env.local +.env.*.local .cache /prisma/data.db @@ -26,3 +28,4 @@ node_modules # generated files /app/components/ui/icons .react-router/ +/types/env-vars.d.ts diff --git a/.prettierignore b/.prettierignore index f022d02..81afeda 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,6 +4,7 @@ node_modules /public/build /server-build .env +.env.* /test-results/ /playwright-report/ @@ -11,5 +12,6 @@ node_modules /tests/fixtures/email/*.json /coverage /prisma/migrations +/types/env-vars.d.ts package-lock.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 3c0a690..7eb65d6 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -6,6 +6,7 @@ "prisma.prisma", "qwtel.sqlite-viewer", "yoavbls.pretty-ts-errors", - "github.vscode-github-actions" + "github.vscode-github-actions", + "varlock.env-spec-language" ] } diff --git a/eslint.config.js b/eslint.config.js index eede0cf..df24093 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -9,6 +9,9 @@ export default [ rules: { 'react-hooks/rules-of-hooks': 'off' }, }, { - ignores: ['.react-router/*'], + ignores: [ + '.react-router/*', + 'types/env-vars.d.ts' + ], }, ] diff --git a/index.js b/index.js index 082cd60..7e60750 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -import 'dotenv/config' +import 'varlock/auto-load' import * as fs from 'node:fs' import sourceMapSupport from 'source-map-support' diff --git a/other/Dockerfile b/other/Dockerfile index a801036..4fbdc04 100644 --- a/other/Dockerfile +++ b/other/Dockerfile @@ -74,7 +74,7 @@ RUN echo "#!/bin/sh\nset -x\nsqlite3 \$CACHE_DATABASE_URL" > /usr/local/bin/cach WORKDIR /myapp -# Generate random value and save it to .env file which will be loaded by dotenv +# Generate random value and save it to .env file which will be loaded by varlock RUN INTERNAL_COMMAND_TOKEN=$(openssl rand -hex 32) && \ echo "INTERNAL_COMMAND_TOKEN=$INTERNAL_COMMAND_TOKEN" > .env diff --git a/package-lock.json b/package-lock.json index af07aec..1d53ea4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,10 @@ { - "name": "epic-stack-with-varlock", + "name": "epic-stack-with-varlock-a3b4", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "epic-stack-with-varlock", - "license": "MIT", + "name": "epic-stack-with-varlock-a3b4", "dependencies": { "@conform-to/react": "^1.5.0", "@conform-to/zod": "^1.5.0", @@ -48,7 +47,6 @@ "cookie": "^1.0.2", "cross-env": "^7.0.3", "date-fns": "^4.1.0", - "dotenv": "^16.5.0", "execa": "^9.5.2", "express": "^4.21.2", "express-rate-limit": "^7.5.0", @@ -77,6 +75,7 @@ "spin-delay": "^2.0.1", "tailwind-merge": "^3.2.0", "tailwindcss": "^4.1.5", + "varlock": "^0.1.2", "vite-env-only": "^3.0.3", "zod": "^3.24.4" }, @@ -1117,6 +1116,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@env-spec/parser": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@env-spec/parser/-/parser-0.0.7.tgz", + "integrity": "sha512-PK4jVwAZA+5aa3PzVF/We48wA9r1S6GRoZH6oSf/zWvNLc9LErynLbnEmmfLBo67KVqRvaur2a7aBj3H1Mpj2w==", + "license": "MIT" + }, "node_modules/@epic-web/cachified": { "version": "5.5.2", "resolved": "https://registry.npmjs.org/@epic-web/cachified/-/cachified-5.5.2.tgz", @@ -9406,9 +9411,9 @@ } }, "node_modules/debug": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", - "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -16281,9 +16286,9 @@ } }, "node_modules/semver": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", - "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -17949,6 +17954,49 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/varlock": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/varlock/-/varlock-0.1.2.tgz", + "integrity": "sha512-f3FuScvIIlcF0t6HZUxtSCwxuc96C2eDx/KYdIv648NdvNg+jCQc0l70782snSPT8Mc49J3GiCXh6aZcy/OIeg==", + "license": "MIT", + "dependencies": { + "@env-spec/parser": "^0.0.7", + "debug": "^4.4.3", + "execa": "^9.6.0", + "semver": "^7.7.3", + "which": "^5.0.0" + }, + "bin": { + "varlock": "bin/cli.js" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/varlock/node_modules/isexe": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", + "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", + "license": "ISC", + "engines": { + "node": ">=16" + } + }, + "node_modules/varlock/node_modules/which": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-5.0.0.tgz", + "integrity": "sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==", + "license": "ISC", + "dependencies": { + "isexe": "^3.1.1" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", diff --git a/package.json b/package.json index a673cf7..65350a8 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "build": "run-s build:*", "build:remix": "react-router build", "build:server": "tsx ./other/build-server.ts", - "dev": "cross-env NODE_ENV=development MOCKS=true node ./server/dev-server.js", - "dev:no-mocks": "cross-env NODE_ENV=development node ./server/dev-server.js", + "dev": "cross-env node ./server/dev-server.js", + "dev:no-mocks": "cross-env MOCKS=false node ./server/dev-server.js", "format": "prettier --write .", "lint": "eslint .", "setup": "npm run build && prisma migrate deploy && prisma generate --sql && playwright install", @@ -78,7 +78,6 @@ "cookie": "^1.0.2", "cross-env": "^7.0.3", "date-fns": "^4.1.0", - "dotenv": "^16.5.0", "execa": "^9.5.2", "express": "^4.21.2", "express-rate-limit": "^7.5.0", diff --git a/playwright.config.ts b/playwright.config.ts index e5d832d..fed00fb 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,5 +1,5 @@ +import 'varlock/auto-load' import { defineConfig, devices } from '@playwright/test' -import 'dotenv/config' const PORT = process.env.PORT || '3000' diff --git a/prisma.config.ts b/prisma.config.ts new file mode 100644 index 0000000..4fcbd13 --- /dev/null +++ b/prisma.config.ts @@ -0,0 +1,8 @@ +// This helps load DATABASE_URL into prisma + +import 'varlock/auto-load' // this loads DATABASE_URL +import { defineConfig } from 'prisma/config' + +export default defineConfig({ + earlyAccess: true, // TS type in this prisma version requires this, but should go away in future +}) \ No newline at end of file diff --git a/tests/setup/global-setup.ts b/tests/setup/global-setup.ts index a81d74d..68c1c11 100644 --- a/tests/setup/global-setup.ts +++ b/tests/setup/global-setup.ts @@ -1,7 +1,7 @@ +import 'varlock/auto-load' import path from 'node:path' import { execaCommand } from 'execa' import fsExtra from 'fs-extra' -import 'dotenv/config' import '#app/utils/env.server.ts' import '#app/utils/cache.server.ts' diff --git a/tests/setup/setup-test-env.ts b/tests/setup/setup-test-env.ts index 8987c43..f11883e 100644 --- a/tests/setup/setup-test-env.ts +++ b/tests/setup/setup-test-env.ts @@ -1,4 +1,4 @@ -import 'dotenv/config' +import 'varlock/auto-load' import './db-setup.ts' import '#app/utils/env.server.ts' // we need these to be imported first 👆 From 173220c97c2ce735e4e8c6d328aa89f0385f10c7 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Thu, 20 Nov 2025 15:38:09 -0300 Subject: [PATCH 3/6] remove zod env validation --- app/entry.server.tsx | 3 +-- app/utils/env.server.ts | 49 ----------------------------------------- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/app/entry.server.tsx b/app/entry.server.tsx index 99fdd4b..3cf2a30 100644 --- a/app/entry.server.tsx +++ b/app/entry.server.tsx @@ -12,14 +12,13 @@ import { type ActionFunctionArgs, type HandleDocumentRequestFunction, } from 'react-router' -import { getEnv, init } from './utils/env.server.ts' +import { getEnv } from './utils/env.server.ts' import { getInstanceInfo } from './utils/litefs.server.ts' import { NonceProvider } from './utils/nonce-provider.ts' import { makeTimings } from './utils/timing.server.ts' export const streamTimeout = 5000 -init() global.ENV = getEnv() const MODE = process.env.NODE_ENV ?? 'development' diff --git a/app/utils/env.server.ts b/app/utils/env.server.ts index e762b1e..609c7f1 100644 --- a/app/utils/env.server.ts +++ b/app/utils/env.server.ts @@ -1,52 +1,3 @@ -import { z } from 'zod' - -const schema = z.object({ - NODE_ENV: z.enum(['production', 'development', 'test'] as const), - DATABASE_PATH: z.string(), - DATABASE_URL: z.string(), - SESSION_SECRET: z.string(), - INTERNAL_COMMAND_TOKEN: z.string(), - HONEYPOT_SECRET: z.string(), - CACHE_DATABASE_PATH: z.string(), - // If you plan on using Sentry, remove the .optional() - SENTRY_DSN: z.string().optional(), - // If you plan to use Resend, remove the .optional() - RESEND_API_KEY: z.string().optional(), - // If you plan to use GitHub auth, remove the .optional() - GITHUB_CLIENT_ID: z.string().optional(), - GITHUB_CLIENT_SECRET: z.string().optional(), - GITHUB_REDIRECT_URI: z.string().optional(), - GITHUB_TOKEN: z.string().optional(), - - ALLOW_INDEXING: z.enum(['true', 'false']).optional(), - - // Tigris Object Storage Configuration - AWS_ACCESS_KEY_ID: z.string(), - AWS_SECRET_ACCESS_KEY: z.string(), - AWS_REGION: z.string(), - AWS_ENDPOINT_URL_S3: z.string().url(), - BUCKET_NAME: z.string(), -}) - -declare global { - namespace NodeJS { - interface ProcessEnv extends z.infer {} - } -} - -export function init() { - const parsed = schema.safeParse(process.env) - - if (parsed.success === false) { - console.error( - '❌ Invalid environment variables:', - parsed.error.flatten().fieldErrors, - ) - - throw new Error('Invalid environment variables') - } -} - /** * This is used in both `entry.server.ts` and `root.tsx` to ensure that * the environment variables are set and globally available before the app is From fb0ad1aaa94181b9e5f9211a09cbeb47fce32244 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Thu, 20 Nov 2025 15:42:40 -0300 Subject: [PATCH 4/6] use varlock ENV instead of process.env --- app/entry.client.tsx | 1 + app/entry.server.tsx | 19 ++--- app/root.tsx | 18 +---- .../_auth/auth.$provider/callback.test.ts | 3 +- app/routes/_auth/webauthn/utils.server.ts | 5 +- app/routes/admin/cache/sqlite.server.ts | 5 +- app/routes/resources/images.tsx | 5 +- app/utils/cache.server.ts | 3 +- app/utils/email.server.ts | 5 +- app/utils/env.server.ts | 25 ------ app/utils/honeypot.server.ts | 5 +- app/utils/monitoring.client.tsx | 1 + app/utils/providers/github.server.ts | 21 ++--- app/utils/session.server.ts | 5 +- app/utils/storage.server.ts | 19 ++--- app/utils/toast.server.ts | 5 +- app/utils/verification.server.ts | 5 +- index.js | 5 +- package-lock.json | 17 ++++ package.json | 1 + server/dev-server.js | 1 + server/index.ts | 23 +++--- server/utils/monitoring.ts | 7 +- tests/e2e/notes.test.ts | 79 +++++++++++++++++++ tests/e2e/search.test.ts | 29 +++++++ tests/mocks/github.ts | 5 +- tests/mocks/index.ts | 3 +- tests/mocks/tigris.ts | 7 +- tests/setup/global-setup.ts | 1 - tests/setup/setup-test-env.ts | 1 - vite.config.ts | 19 +++-- 31 files changed, 222 insertions(+), 126 deletions(-) delete mode 100644 app/utils/env.server.ts create mode 100644 tests/e2e/notes.test.ts create mode 100644 tests/e2e/search.test.ts diff --git a/app/entry.client.tsx b/app/entry.client.tsx index 9b7749f..6998451 100644 --- a/app/entry.client.tsx +++ b/app/entry.client.tsx @@ -1,6 +1,7 @@ import { startTransition } from 'react' import { hydrateRoot } from 'react-dom/client' import { HydratedRouter } from 'react-router/dom' +import { ENV } from 'varlock/env' if (ENV.MODE === 'production' && ENV.SENTRY_DSN) { void import('./utils/monitoring.client.tsx').then(({ init }) => init()) diff --git a/app/entry.server.tsx b/app/entry.server.tsx index 3cf2a30..f1c7cbd 100644 --- a/app/entry.server.tsx +++ b/app/entry.server.tsx @@ -12,16 +12,13 @@ import { type ActionFunctionArgs, type HandleDocumentRequestFunction, } from 'react-router' -import { getEnv } from './utils/env.server.ts' +import { ENV } from 'varlock/env' import { getInstanceInfo } from './utils/litefs.server.ts' import { NonceProvider } from './utils/nonce-provider.ts' import { makeTimings } from './utils/timing.server.ts' export const streamTimeout = 5000 -global.ENV = getEnv() - -const MODE = process.env.NODE_ENV ?? 'development' type DocRequestArgs = Parameters @@ -29,12 +26,12 @@ export default async function handleRequest(...args: DocRequestArgs) { const [request, responseStatusCode, responseHeaders, reactRouterContext] = args const { currentInstance, primaryInstance } = await getInstanceInfo() - responseHeaders.set('fly-region', process.env.FLY_REGION ?? 'unknown') - responseHeaders.set('fly-app', process.env.FLY_APP_NAME ?? 'unknown') + responseHeaders.set('fly-region', ENV.FLY_REGION ?? 'unknown') + responseHeaders.set('fly-app', ENV.FLY_APP_NAME ?? 'unknown') responseHeaders.set('fly-primary-instance', primaryInstance) responseHeaders.set('fly-instance', currentInstance) - if (process.env.NODE_ENV === 'production' && process.env.SENTRY_DSN) { + if (ENV.NODE_ENV === 'production' && ENV.SENTRY_DSN) { responseHeaders.append('Document-Policy', 'js-profiling') } @@ -71,8 +68,8 @@ export default async function handleRequest(...args: DocRequestArgs) { directives: { fetch: { 'connect-src': [ - MODE === 'development' ? 'ws:' : undefined, - process.env.SENTRY_DSN ? '*.sentry.io' : undefined, + ENV.MODE === 'development' ? 'ws:' : undefined, + ENV.SENTRY_DSN ? '*.sentry.io' : undefined, "'self'", ], 'font-src': ["'self'"], @@ -113,8 +110,8 @@ export default async function handleRequest(...args: DocRequestArgs) { export async function handleDataRequest(response: Response) { const { currentInstance, primaryInstance } = await getInstanceInfo() - response.headers.set('fly-region', process.env.FLY_REGION ?? 'unknown') - response.headers.set('fly-app', process.env.FLY_APP_NAME ?? 'unknown') + response.headers.set('fly-region', ENV.FLY_REGION ?? 'unknown') + response.headers.set('fly-app', ENV.FLY_APP_NAME ?? 'unknown') response.headers.set('fly-primary-instance', primaryInstance) response.headers.set('fly-instance', currentInstance) diff --git a/app/root.tsx b/app/root.tsx index 3b19435..93038c1 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -11,6 +11,7 @@ import { useMatches, } from 'react-router' import { HoneypotProvider } from 'remix-utils/honeypot/react' +import { ENV } from 'varlock/env' import { type Route } from './+types/root.ts' import appleTouchIconAssetUrl from './assets/favicons/apple-touch-icon.png' import faviconAssetUrl from './assets/favicons/favicon.svg' @@ -31,7 +32,6 @@ import tailwindStyleSheetUrl from './styles/tailwind.css?url' import { getUserId, logout } from './utils/auth.server.ts' import { ClientHintCheck, getHints } from './utils/client-hints.tsx' import { prisma } from './utils/db.server.ts' -import { getEnv } from './utils/env.server.ts' import { pipeHeaders } from './utils/headers.server.ts' import { honeypot } from './utils/honeypot.server.ts' import { combineHeaders, getDomainUrl, getImgSrc } from './utils/misc.tsx' @@ -119,7 +119,6 @@ export async function loader({ request }: Route.LoaderArgs) { theme: getTheme(request), }, }, - ENV: getEnv(), toast, honeyProps, }, @@ -138,14 +137,11 @@ function Document({ children, nonce, theme = 'light', - env = {}, }: { children: React.ReactNode nonce: string theme?: Theme - env?: Record }) { - const allowIndexing = ENV.ALLOW_INDEXING !== 'false' return ( @@ -153,19 +149,13 @@ function Document({ - {allowIndexing ? null : ( + {ENV.ALLOW_INDEXING ? null : ( )} {children} -