Skip to content

Support optional subdomain for reverse proxy domains#589

Merged
heisbrot merged 1 commit intomainfrom
feature/require-subdomain-validation
Mar 24, 2026
Merged

Support optional subdomain for reverse proxy domains#589
heisbrot merged 1 commit intomainfrom
feature/require-subdomain-validation

Conversation

@lixmal
Copy link
Copy Markdown
Contributor

@lixmal lixmal commented Mar 19, 2026

Summary

  • Add require_subdomain field to ReverseProxyDomain interface
  • When require_subdomain is not explicitly true, subdomain input becomes optional
  • Adapt help text and placeholder when subdomain is optional
  • Fix parseDomain to handle bare domain when editing existing services
  • Fix fullDomain assembly for empty subdomain case

Backend: netbirdio/netbird#5628

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

An optional require_subdomain field was added to the reverse proxy domain configuration interface. The validation logic was updated to conditionally require subdomains based on domain configuration, and UI messaging and domain parsing were adjusted to support both subdomain-based and direct domain usage.

Changes

Cohort / File(s) Summary
Interface Extension
src/interfaces/ReverseProxy.ts
Added optional require_subdomain?: boolean property to ReverseProxyDomain interface to support flexible domain configuration.
Validation & Props
src/modules/reverse-proxy/ReverseProxyModal.tsx
Updated canContinueToSettings validation to conditionally require subdomain based on domain configuration; extended hook dependencies and passed subdomainRequired prop to downstream component.
UI Input & Messaging
src/modules/reverse-proxy/domain/ReverseProxyDomainInput.tsx
Added subdomainRequired prop to component; updated help text and placeholder messaging to reflect optional vs. required subdomain states.
Domain Parsing Logic
src/modules/reverse-proxy/domain/useReverseProxyDomain.ts
Enhanced parseDomain to handle exact domain matches; updated fullDomain computation to avoid subdomain prefix concatenation when subdomain is empty.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A domain so flexible, neat!
With subdomains now optional, sweet,
The config extends with grace,
Validation finds its place,
While parsing makes the flow complete! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Support optional subdomain for reverse proxy domains' accurately and concisely describes the main change: adding optional subdomain support to reverse proxy domain configuration, which is implemented across all modified files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/require-subdomain-validation
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/modules/reverse-proxy/ReverseProxyModal.tsx (1)

251-253: Consider deriving subdomainRequired once to avoid logic drift.

The same condition is duplicated in validation and render props. Hoisting it improves maintainability and keeps both paths guaranteed in sync.

🧹 Suggested cleanup
   const selectedDomain = useMemo(
     () =>
       domains?.find(
         (d) => d.domain === baseDomain || d.target_cluster === baseDomain,
       ),
     [domains, baseDomain],
   );
+  const subdomainRequired = selectedDomain?.require_subdomain === true;

   const canContinueToSettings = useMemo(() => {
-    const subdomainRequired =
-      selectedDomain?.require_subdomain === true;
     const isSubdomainValid =
       baseDomain.length > 0 &&
       !domainAlreadyExists &&
       (subdomain.length > 0 || !subdomainRequired);
@@
   }, [
     subdomain,
     baseDomain,
     domainAlreadyExists,
-    selectedDomain,
+    subdomainRequired,
     serviceMode,
@@
               <ReverseProxyDomainInput
                 subdomain={subdomain}
                 onSubdomainChange={setSubdomain}
                 baseDomain={baseDomain}
                 onBaseDomainChange={setBaseDomain}
                 domainAlreadyExists={domainAlreadyExists}
-                subdomainRequired={selectedDomain?.require_subdomain === true}
+                subdomainRequired={subdomainRequired}
                 clusterOffline={

Also applies to: 271-271, 452-452

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/reverse-proxy/ReverseProxyModal.tsx` around lines 251 - 253,
Derive and reuse a single boolean for the "require subdomain" check instead of
repeating the condition: define const subdomainRequired =
selectedDomain?.require_subdomain === true (or similar) once near the top of
ReverseProxyModal and replace any duplicated checks in the validation logic and
in the render/JSX props with that variable (references: subdomainRequired,
selectedDomain, validation function, and render props using the same condition)
so both validation and rendering always stay in sync.
src/modules/reverse-proxy/domain/ReverseProxyDomainInput.tsx (1)

35-37: Expose required state to the input when subdomain is mandatory.

The validation logic now distinguishes required vs optional subdomain; reflecting that via input attributes will improve accessibility and browser semantics.

♿ Suggested update
           <Input
             autoFocus
             value={subdomain}
+            required={subdomainRequired}
+            aria-required={subdomainRequired}
             onChange={(e) => {
               onSubdomainChange(
                 e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ""),
               );
             }}

Also applies to: 54-56

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/reverse-proxy/domain/ReverseProxyDomainInput.tsx` around lines 35
- 37, The subdomain input should reflect the validation state: in
ReverseProxyDomainInput, when subdomainRequired is true set the subdomain input
element's required attribute and aria-required="true" (and remove/set to false
when not required) so browsers and assistive tech know it's mandatory; update
both places where the subdomain input is rendered (the block using
subdomainRequired around the helper text and the repeated rendering at the
second occurrence) to toggle required/aria-required based on the
subdomainRequired symbol.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/modules/reverse-proxy/domain/ReverseProxyDomainInput.tsx`:
- Around line 35-37: The subdomain input should reflect the validation state: in
ReverseProxyDomainInput, when subdomainRequired is true set the subdomain input
element's required attribute and aria-required="true" (and remove/set to false
when not required) so browsers and assistive tech know it's mandatory; update
both places where the subdomain input is rendered (the block using
subdomainRequired around the helper text and the repeated rendering at the
second occurrence) to toggle required/aria-required based on the
subdomainRequired symbol.

In `@src/modules/reverse-proxy/ReverseProxyModal.tsx`:
- Around line 251-253: Derive and reuse a single boolean for the "require
subdomain" check instead of repeating the condition: define const
subdomainRequired = selectedDomain?.require_subdomain === true (or similar) once
near the top of ReverseProxyModal and replace any duplicated checks in the
validation logic and in the render/JSX props with that variable (references:
subdomainRequired, selectedDomain, validation function, and render props using
the same condition) so both validation and rendering always stay in sync.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a0f09192-e4b7-4386-be90-4ed6e9b5615e

📥 Commits

Reviewing files that changed from the base of the PR and between aff2365 and 2b712ce.

📒 Files selected for processing (4)
  • src/interfaces/ReverseProxy.ts
  • src/modules/reverse-proxy/ReverseProxyModal.tsx
  • src/modules/reverse-proxy/domain/ReverseProxyDomainInput.tsx
  • src/modules/reverse-proxy/domain/useReverseProxyDomain.ts

@heisbrot heisbrot merged commit 8c283b6 into main Mar 24, 2026
4 checks passed
@heisbrot heisbrot deleted the feature/require-subdomain-validation branch March 24, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants