FieldOps/.env.example
Pedro Gomes 4cc7f2f121 MAI CALL - step 8 +
Passo 8 completo. Tudo verde. Sumário do que foi feito:

Novas páginas:

app/select-operator/page.tsx — Server Component; redireciona automaticamente se já há sessão; lista operadores via prisma direto (funciona mesmo sem sessão ativa)
app/select-operator/operator-picker.tsx — Client Component; tap → signIn('credentials', { email, redirect: false }) → redireciona para /
app/sign-out-button.tsx — botão "Trocar" que chama signOut → volta ao picker
middleware.ts atualizado — redireciona para /select-operator quando não há sessão e AUTH_DEV_AUTOLOGIN=false; skip automático se já logado; o picker não faz redirect se não há sessão (deixa carregar)

app/page.tsx atualizado — mostra chip com o email do utilizador atual + botão "Trocar" (necessário para o AC "header mostra op1@demo.local")

Correções de infraestrutura descobertas:

NODE_ENV="development" removido do .env — estava a forçar o runtime de dev no next build, quebrando a geração estática
pages/_error.tsx adicionado — override mínimo que previne o erro <Html> outside _document
@repo/storage adicionado a transpilePackages e AWS SDK marcado como serverExternalPackages
app/not-found.tsx + app/error.tsx adicionados para App Router
AC verificado: build de produção passa limpo em Next.js 15.3.9 com todas as rotas correctas. O fluxo demo (/ → picker → login → / mostra email) funciona via dev server.
2026-05-16 16:19:15 +01:00

46 lines
1.9 KiB
Plaintext

# ---------------------------------------------------------------------------
# FieldOps — environment variables
# ---------------------------------------------------------------------------
# Copy this file to .env (cp .env.example .env) and adjust as needed for your
# local environment. Never commit .env.
# Postgres connection string. Matches docker-compose.yml defaults.
DATABASE_URL="postgresql://fieldops:fieldops@localhost:5432/fieldops?schema=public"
# Auth.js v5 — secret used to sign session tokens.
# In production, set this to a strong random value: `openssl rand -base64 32`.
AUTH_SECRET="dev-secret-do-not-use-in-production-please-change-me"
# Dev-only auto sign-in.
# When set to "true", the app will silently sign in as the seed admin user
# (admin@demo.local of the "Demo Factory" tenant) on every request that has
# no session. This skips the login UI in local development and CI/E2E.
#
# !!! NEVER set this to "true" in production. !!!
# The default of "false" here is intentional — a developer setting up locally
# must consciously opt in by editing their .env. See README "Auth" section.
AUTH_DEV_AUTOLOGIN="false"
# Base URL of the operator-pwa app — used by Auth.js for callback URLs.
NEXT_PUBLIC_APP_URL="http://localhost:3000"
AUTH_URL="http://localhost:3000"
# Pino log level — one of: fatal, error, warn, info, debug, trace.
LOG_LEVEL="info"
# Node environment — intentionally NOT set here.
# Next.js sets NODE_ENV automatically (development/production/test).
# Setting it via dotenv-cli before `next build` forces the dev runtime and
# breaks static page generation.
# MinIO / S3-compatible object storage. Matches docker-compose.yml defaults.
# S3_FORCE_PATH_STYLE=true is required for MinIO (and other self-hosted S3 impls).
S3_ENDPOINT="http://localhost:9000"
S3_REGION="us-east-1"
S3_BUCKET="fieldops"
S3_ACCESS_KEY="fieldops"
S3_SECRET_KEY="fieldops123"
S3_FORCE_PATH_STYLE="true"
MINIO_ROOT_USER="fieldops"
MINIO_ROOT_PASSWORD="fieldops123"