Revisiting Sublet

Revisiting Sublet reminded me how much old projects can teach us. With improved domain verification, refined validation, and better error handling, Sublet is now more reliable and resilient—proof that revisiting and refining your work can lead to meaningful progress.

Revisiting Sublet
Photo by Bimo Luki / Unsplash

Revisiting old projects is always fun, especially when it’s been a while since you last looked at the code and you feel like a new user. Stepping back for some time gives you a fresh perspective and lets you notice things that might otherwise go unnoticed.

Sublet is a project I built earlier this year that allows anyone to sublet (i.e., lease/rent subdomains of primary domains they control). It consists of a Node.js backend, a simple Node.js agent packaged neatly into a Docker container, and a Vue frontend.

There are two main functions of Sublet: Leasing, where you lease subdomains from others, and Monetizing, where you lease subdomains to others. The leasing aspect has been proven in the wild, with users successfully purchasing subdomains. My focus during recent updates was on the monetization aspect.

Subdomain Monetization

The original motivation for creating Sublet was to put my domains to better use—particularly the ones I hadn’t had time to develop or for which I hadn’t developed a clear “vision.” Letting them expire wasn’t an option. Sublet provides a simple way to subdelegate subdomains via DNS and potentially cover some or all of the “holding cost.”

While updating the code and making small fixes, everything mostly worked as expected following the quick start guide, which is always satisfying. Some of the updates I implemented include:

Improving the domain ownership verification

We enhanced the domain verification process to make it more reliable and robust. Previously, our Node.js service sometimes failed to resolve TXT records for new domains, even when the record was correctly published. This was caused by a combination of system resolver caching and negative DNS caching at upstream resolvers.

The fix involved:

  • Standardizing label validation: We introduced a reusable validateLabels function to consistently check domain and subdomain labels against allowed characters, forbidden words, and common patterns (e.g., www, ns1, -).
  • Explicit TLD and subdomain checks: Domains must have at least two labels (example.com) and subdomains at least three (a.example.com). Forbidden top-level domains like .example, .localhost, and .test are rejected.
  • Retry-friendly TXT lookups: We now use Node’s dns.promises API with optional custom resolvers to bypass local negative caches. TXT records are verified with a robust join-and-compare approach to ensure the verification code matches exactly.
  • Better error handling: Clear logging now distinguishes between verification failures (wrong TXT content) and lookup errors (ENOTFOUND), simplifying debugging.

These improvements make domain ownership verification consistent, secure, and resilient to transient DNS issues, enhancing reliability for users registering or linking domains.

Fixing subdomain validation for agent configuration

We also resolved an issue where the backend was rejecting valid subdomains during agent registration. Previously, Joi validation was too restrictive, only allowing single-label subdomains or incorrectly enforcing character rules. This caused errors like:

Sublet Agent error
Error sending agent config: Subdomain must be a valid DNS label (1-63 characters, alphanumeric, hyphen)

The fix included:

  • Proper label validation: A reusable validateLabels function now enforces DNS rules consistently:
    • Each label 1–63 characters
    • Alphanumeric characters plus hyphens
    • No leading or trailing hyphens
    • No forbidden keywords or patterns (e.g., www, ns1, -)
  • Support for full subdomains: The schema requires at least three labels for subdomains (a.domain.com) while still allowing standard domains (domain.com) where appropriate.
  • Clearer error messages: Validation errors now specify which rule was violated, making it easier for developers to fix configuration issues.

These updates ensure that agents can register valid subdomains without unnecessary rejections while still preventing invalid or reserved labels.

Conclusion

Revisiting Sublet has been a valuable reminder of how projects evolve over time. Small updates, improved validations, and better error handling not only make the system more reliable but also reinforce the importance of revisiting and refining your work.

Whether it’s for monetization, experimentation, or simply learning, taking the time to step back and review old projects can reveal insights and opportunities that might have been overlooked initially. Sublet continues to grow, and these updates ensure it’s more robust and user-friendly than ever.