Urgent.News

What's breaking now, across thousands of outlets.

Tech

Stop writing the same custom HTTP wrapper in every project

Every time I start a new frontend or full-stack project, the same ritual happens. We install axios or grab native fetch, and within a few weeks, we find ourselves building a massive layer of custom wrappers, interceptors, and helpers around it. Why? Because out-of-the-box HTTP clients handle basic data fetching fine, but they completely ignore real-world app constraints like rapid user actions,…

When starting new frontend or full-stack projects, developers often install HTTP clients like axios or native fetch. Within weeks, they find themselves creating a large layer of custom wrappers, interceptors, and helpers around them. This is because out-of-the-box HTTP clients don't address real-world app concerns such as rapid user actions, duplicated state, and client-side payload security. As a result, each project codebase ends up with its own network utility to tackle four specific issues:

1. In-Flight Request Flooding: Typical HTTP clients make repeated parallel requests to an API when a user double-clicks a button or UI re-renders multiple times. To avoid wasting server resources, developers must write their own AbortController logic or custom flag locks.

2. Payload Security: While HTTPS ensures data is secure in transit, it may not be enough for handling sensitive information like customer data or financial records. Developers often need to import large cryptographic libraries and build custom request/response interceptors for AES-GCM payload encryption on the client-side.

3. Basic TTL Caching: Implementing a simple in-memory cache for short-lived requests can be a challenge. Developers typically have to add on a whole state management library or complex caching layers, adding unnecessary complexity for something as straightforward as request freshness.

4. Boilerplate HMAC Signing: To secure API requests, developers must manually manipulate headers on all outgoing requests, which can be cumbersome and error-prone.

The author, after growing tired of duplicating and re-architecting these four mechanisms in various codebases, created a single helper utility called PHTPS (Pretty HTTP Transport with Payload Security). PHTPS incorporates deduplication, TTL caching, and AES payload encryption natively. Its features include:

- Deduplication: Automatically merges identical in-flight requests

- TTL Caching: In-memory cache for short-lived requests (e.g., 5 seconds)

- AES Payload Encryption: Client-side encryption using AES-GCM

- HMAC Signing: Secure request signing

With PHTPS, developers can handle these common use cases without the need for custom wrappers or extensive re-architecting. The library offers 11 official plugins with documentation and an interactive playground for exploration: https://phtps-app.vercel.app

The author is curious about how others handle request deduplication and client-side encryption in their applications. Are they relying on custom wrappers, or incorporating these features at the state management layer? The author invites feedback and discussion in the comments below.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

The HTTP 429 That Turned Seven Minutes Into Zero Work

This is a submission for DEV's Summer Bug Smash: Smash Stories powered by Sentry . ARGUS is a data-catalog governance swarm.

  • ARGUS data-catalog system experienced seven-minute outage due to HTTP 429 error
  • System treated 429 as temporary, amplifying outage through retry loops

# Stopping S3 Data Exfiltration in Real Time: A Step-by-Step Incident Response

The Scenario An EC2 instance with an attached IAM role has s3:GetObject on a bucket containing sensitive data. An attacker compromises the instance, extracts temporary credentials from the metadata…

  • Identify compromised IAM role using EC2 instance ID and AWS CLI commands
  • Invalidate active sessions with inline deny policy attached to IAM role
  • Verify revocation by checking CloudTrail logs and legitimate access

The Sunday Papers

Sometimes, Sundays are only for rounding up videogame criticism and journalism. I try to cast a wider net when my turn comes to deliver the Papers, because I figure you've probably been reading about videogames all week, and would appreciate e.g.

More from Sunday 23 August →