frontend
Technical notes on web development, DevOps, and AI integration.
173 articles
- 23:51frontend
Asked for 100, Got 20: The Counter Said 54
The limit you send is a hope, not a contract. A list endpoint silently clamped limit 100 down to 20, so a counter reading 54 rendered 20 cards.
TL;DR: The KotaPortal portal displays 20 cards despite a reported total of 54. The server limits requests to 50 and silently reduces larger limits to 20. The fix involves fetching one page at a time.
#react#nextjs#typescript - 22:48frontend
Three 7-Line Routes, One 471-Line Component
The Kelembagaan admin module: three 7-14 line server routes, one 471-line client editor, a 350 ms debounced list, and an id guard that throws 404.
TL;DR: Commit c50f35b adds the Kelembagaan module. It includes organization list and edit forms with validation. Validation occurs on the server side for security.
#nextjs#react#typescript - 20:31frontend
The Server Writes the Title, the Client Fills the List
Server shell, metadata and heading on the server; tabs, a 350 ms debounced search, and the board detail live in one client island.
TL;DR: The page title and metadata are server-rendered. The list is fetched in the browser when the component mounts. Server writes metadata and heading, browser fetches data.
#nextjs#react#seo - 19:06security
The Masked Public Roster: Ship Names, Not Phone Numbers
Hiding sensitive columns in the UI is not protection. The real mask lives in the API layer, proven by negative E2E assertions.
TL;DR: The article describes a common flaw where the UI hides sensitive fields but the API still sends full records to the client, violating OWASP API3:2023 and Indonesia's data minimization rules. The fix strips fields server-side via a projection DTO containing only public data. A Playwright test enforces negative assertions, ensuring PII never reaches the DOM.
#privacy#security#playwright - 23:55backend
Plain Date, Not Instant: the event_date Contract at KotaPortal
The admin event_date once left the browser as an instant T00:00:00Z. The contract now requires a plain YYYY-MM-DD string, with Go validation rejecting instants outright.
TL;DR: A calendar-date field was leaking through the API as a UTC midnight instant, silently accepted by lenient MariaDB and patched over client-side with toLocalDateInput. The fix changes the contract itself: format date, a string DTO, validation at the service edge with a 400 on bad input. Regenerated frontend types now reject instants at compile time, killing the timezone-drift bug class.
#api#openapi#go - 21:32security
Hardening the Next.js Image Optimizer Against SSRF
A wildcard hostname in remotePatterns turns /_next/image into an open server-side fetch proxy. The close-out pattern: local-only, one explicit host, a negative test.
TL;DR: KotaPortal's Next.js image config used a wildcard hostname in remotePatterns, turning the /_next/image endpoint into a potential SSRF vector since it fetches any HTTPS URL server-side. The fix removed the wildcard, allowing only same-origin images plus one explicit Google avatar host in both remotePatterns and CSP. A negative end-to-end test now verifies unlisted hosts get rejected.
#nextjs#next-image#ssrf - 05:23backend
Schedule Conflict Checks as a Warning, Not a Wall
A booking form that warns about schedule clashes without blocking: read-only endpoint, inclusive overlap query, debounce and abort.
TL;DR: A hall got double-booked because two officers approved overlapping applications without checking each other, and the old form couldn't flag taken dates. The shipped fix pairs a validated, read-only endpoint that flags overlapping schedules with a debounced, race-safe warning box on the form. The warning never blocks submission; the officer still decides.
#go#mysql#react - 01:35security
When the Server Fails Closed, the Interface Must Tell the Truth
The server refused free uploads from scoped editors while the UI kept offering the button. Gating the picker fixed the affordance, not the security.
TL;DR: Scoped editors could see KotaPortal's media upload button but always hit a 403, since only admin-global accounts could upload free. The fix gates the button, file input, and handler behind the same server-side permission check, so the UI stops promising what the server refuses. Lesson: hiding UI is hygiene, not enforcement; the server remains the real gate.
#rbac#react#ux - 13:51frontend
The Date That Shifted by Itself: Pin the Timezone at Render
Data right, display wrong: toLocaleString without timeZone lets a UTC server and a WIB browser render different dates. Pin it at the presentation layer.
TL;DR: A date bug blamed on stored data was actually the render layer: toLocaleString was called with the id-ID locale but no timeZone option, so servers in UTC and browsers in WIB disagreed. Timestamps between 17:00 and 24:00 UTC crossed midnight once converted. Fix: store UTC, render with an explicit timeZone, locked by a test.
#frontend#nextjs#timezone