- ecosystem.config.cjs: NODE_ENV was hardcoded to "development" even for the production pm2 process, silently disabling every isDevEnv()-gated security check (API key bypass, admin auth bypass) in production. Now "production". - Restrict CORS via configurable CORS_ALLOWED_ORIGINS (falls back to allow-all with a warning when unset, so this doesn't break existing traffic on deploy). - Add an in-process, dependency-free rate limiter on /createtransaksi, /api/payment-links, /api/payments/charge, and /api/payments/snap/token to curb bot abuse / card-testing on endpoints the browser checkout must be able to call directly (an API-key gate would break that legitimate flow). - Auto-delete LOGS_*.log files older than LOG_RETENTION_DAYS (default 30). - Persist activeOrders, notifiedOrders, orderRetryCount, and orderMerchantId to server/data/state.json via Proxy-wrapped Map/Set (schedulePersist on every mutation), so idempotency and retry-suffix tracking survive restarts/crashes instead of resetting to empty every deploy. - Remove processPaymentCompletion, dead code with no call sites. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> |
||
|---|---|---|
| postman | ||
| public | ||
| scripts | ||
| server | ||
| src | ||
| tests | ||
| .gitignore | ||
| README.md | ||
| ecosystem.config.cjs | ||
| eslint.config.js | ||
| index.html | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.cjs | ||
| tailwind.config.ts | ||
| tsconfig.app.json | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| vite.config.ts | ||
README.md
Core Midtrans CIFO (Frontend)
Frontend Vite + React untuk integrasi Midtrans Core API dengan UI kustom.
Setup
- Duplikasi file contoh env dan isi nilainya:
cp .env.example .env.local
Isi .env.local (lihat .env.example untuk referensi):
VITE_API_BASE_URL=http://localhost:8000/api
VITE_MIDTRANS_CLIENT_KEY=YOUR_CLIENT_KEY
VITE_MIDTRANS_ENV=sandbox
- Jalankan pengembangan:
npm install
npm run dev
App akan tersedia di http://localhost:5173/ (atau port lain jika 5173 dipakai).
Catatan Integrasi Midtrans
- Client Key hanya digunakan di frontend (mis. tokenisasi kartu/3DS). Server Key TIDAK pernah di frontend.
- Semua request ke Midtrans dilakukan lewat backend (
VITE_API_BASE_URL). Frontend memanggil endpoint seperti/payments/:orderId/status. - Status real-time dapat diimplementasikan via polling (TanStack Query) atau SSE/WebSocket dari backend.
Struktur Env di Kode
- Akses env melalui modul
src/lib/env.ts:Env.API_BASE_URLEnv.MIDTRANS_CLIENT_KEYEnv.MIDTRANS_ENV
Lisensi
Internal project skeleton.