Remove hard-coded domains; default to localhost and env config

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kirukib 2026-11-17 23:02:38 +03:00
parent 7b3b9c5943
commit 97730f2f2d
6 changed files with 10 additions and 10 deletions

View File

@ -6,15 +6,15 @@ PORT=4000
# 32+ random chars: openssl rand -hex 32
JWT_SECRET=change-me-change-me-change-me-change-me
# Comma-separated. Anyone else who logs in is an ATTENDEE.
ADMIN_EMAILS=tech@ethiopiatrustfund.org
ADMIN_EMAILS=admin@example.com
STAFF_EMAILS=
# Browser origins allowed to call the API (site, admin). The mobile app needs none.
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
SITE_URL=https://grv.ethiopiatrustfund.org
SITE_URL=http://localhost:3000
ADMIN_URL=http://localhost:5173
# Empty RESEND_API_KEY = emails (and OTP codes) are printed to the console instead of sent.
RESEND_API_KEY=
RESEND_FROM=GRV Summit <grv@ethiopiatrustfund.org>
NOTIFY_TO=tech@ethiopiatrustfund.org
RESEND_FROM=GRV Summit <onboarding@resend.dev>
NOTIFY_TO=admin@example.com
# Shown to buyers after a ticket order until a payment gateway is wired.
PAYMENT_INSTRUCTIONS=Our team will email you an invoice with bank transfer details within one business day. Your tickets are issued once payment is confirmed.

2
API.md
View File

@ -9,7 +9,7 @@ JSON in and out. Money is integer minor units (cents) with a `currency` (`"USD"`
(`ADMIN_EMAILS` / `STAFF_EMAILS` env allowlists, otherwise `ATTENDEE`). In dev the OTP is printed to the backend console.
There is no refresh token: attendee tokens last 30 days, staff/admin tokens 12 hours. On 401, log out and ask for a new code.
QR codes encode a URL: checkpoints `https://grv.ethiopiatrustfund.org/q/<qrToken>`, tickets `.../t/<qrToken>`.
QR codes encode a URL: checkpoints `<SITE_URL>/q/<qrToken>`, tickets `<SITE_URL>/t/<qrToken>`.
`POST /scan` accepts either the full URL or the bare token.
## Shared shapes

View File

@ -48,7 +48,7 @@ pnpm install --frozen-lockfile && pnpm build && pnpm db:migrate && pnpm db:seed
pm2 start dist/src/main.js --name grv-backend # NODE_ENV=production, env from .env
```
Put it behind HTTPS (e.g. `api.grv.ethiopiatrustfund.org`). Set `CORS_ORIGINS` to the site and admin origins and `ADMIN_URL` to the admin's URL (used in staff emails).
Put it behind HTTPS. Set `CORS_ORIGINS` to the site and admin origins and `ADMIN_URL` to the admin's URL (used in staff emails).
## Not built yet

View File

@ -3,7 +3,7 @@ import 'dotenv/config';
const list = (v: string | undefined) =>
(v ?? '').split(',').map((s) => s.trim().toLowerCase()).filter(Boolean);
export const SITE_URL = (process.env.SITE_URL || 'https://grv.ethiopiatrustfund.org').replace(/\/$/, '');
export const SITE_URL = (process.env.SITE_URL || 'http://localhost:3000').replace(/\/$/, '');
export const ADMIN_URL = (process.env.ADMIN_URL || 'http://localhost:5173').replace(/\/$/, '');
export const env = {

View File

@ -21,7 +21,7 @@ export async function sendMail(mail: Mail) {
method: 'POST',
headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
from: process.env.RESEND_FROM || 'GRV Summit <grv@ethiopiatrustfund.org>',
from: process.env.RESEND_FROM || 'GRV Summit <onboarding@resend.dev>',
to: mail.to,
subject: mail.subject,
html: mail.html,
@ -34,7 +34,7 @@ export async function sendMail(mail: Mail) {
return json.id;
}
export const staffInbox = () => process.env.NOTIFY_TO || 'tech@ethiopiatrustfund.org';
export const staffInbox = () => process.env.NOTIFY_TO || (process.env.ADMIN_EMAILS ?? '').split(',')[0].trim();
/** Fire-and-forget for flows whose data is already saved: failures are logged, never thrown. */
export function sendInBackground(label: string, mails: Mail[]) {

View File

@ -78,7 +78,7 @@ describe('scans', () => {
const booth = await prisma.checkpoint.create({ data: { kind: 'BOOTH', label: 'B', points: 10, qrToken: 'booth1' } });
await prisma.checkpoint.create({ data: { kind: 'MYSTERY_INVESTEE', label: 'M', points: 50, qrToken: 'myst1' } });
expect((await game.scan(user, `https://grv.ethiopiatrustfund.org/q/${booth.qrToken}`)).total).toBe(10);
expect((await game.scan(user, `http://localhost:3000/q/${booth.qrToken}`)).total).toBe(10);
await expect(game.scan(user, 'booth1')).rejects.toMatchObject({ status: 409 });
const mystery = await game.scan(user, 'myst1');
expect(mystery).toMatchObject({ pointsAwarded: 100, total: 110, mystery: true });