Skip to content

feat(domains): Set response streaming, headers, redirects and access limits - #122

Merged
nfebe merged 3 commits into
mainfrom
feat/proxy-tuning
Oct 27, 2026
Merged

nfebe merged 3 commits into
mainfrom
feat/proxy-tuning

Conversation

@nfebe

@nfebe nfebe commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Add streaming, response headers, the alias redirect, basic auth and the IP allow-list to the domain form. Saved users come back by name only, so the form never holds the stored hashes.

…limits

The domain form now sets streaming responses, custom response headers,
a redirect from aliases to the primary domain, a username and password,
and an IP allow-list, which before needed hand edits to the proxy config.

Saved users are sent back by name only, so editing a domain keeps their
passwords without the form ever holding the stored hashes. Values the
proxy would reject are flagged in the form before saving.
@sourceant

sourceant Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Code Review Summary

The domain form gains sections for response streaming, added response headers, basic auth and an IP allow-list, plus an alias-to-primary redirect toggle that only appears when aliases exist. Every new field is validated client-side before save, so malformed header names, duplicate headers or usernames, bad IPv4/IPv6 or CIDR entries and password-less new users prevent submission. Saved basic-auth users come back by username only, so stored hashes never reach the form and an empty password preserves the stored one.

🚀 Key Improvements

  • Saved basic-auth users round-trip by username alone, so password hashes never enter the form.
  • Validation rejects header, username and IP/CIDR input the proxy would refuse before saving.
  • The alias redirect option is hidden and automatically dropped when the domain has no aliases.

💡 Minor Suggestions

  • filter(Boolean) hides empty groups, so malformed addresses such as :1:2:3:4:5:6:7:8 and ::: pass validIPv6 and are written into the allow-list, where nginx refuses the whole site config. Split on :: and validate every group instead of dropping empty ones.
  • Review coverage is incomplete. Inspect the execution details before approving.

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review complete. See the overview comment for a summary.

.filter(Boolean);
}

const allowIPsError = computed(() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The pattern matches any hex-ish string, so 999.999.999.999, cafe, 1.2.3.4.5 or 10.0.0.0/999 pass validation and are saved into the proxy's allow-list, where nginx then refuses the config. Validate IPv4 octets and CIDR prefix ranges (and bound IPv6) instead of accepting [0-9A-Fa-f:.]+.

Suggested change
const allowIPsError = computed(() => {
const IPV4_OR_CIDR =
/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\/(?:3[0-2]|[12]?\d))?$/;
const IPV6_OR_CIDR = /^(?:[0-9A-Fa-f]{0,4}:){2,7}[0-9A-Fa-f]{0,4}(?:\/(?:12[0-8]|1[01]\d|[1-9]?\d))?$/;
const allowIPsError = computed(() => {
const bad = allowIPs().find((entry) => !IPV4_OR_CIDR.test(entry) && !IPV6_OR_CIDR.test(entry));
return bad ? `${bad} is not an IP address or CIDR range.` : "";
});

return "";
});

const headersError = computed(() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Two rows with the same header name both validate, but responseHeaders() builds a Record, so Object.fromEntries keeps only the last one and silently drops the other. Reject duplicates here, as basicAuthError already does for usernames.

Suggested change
const headersError = computed(() => {
const headersError = computed(() => {
const seen = new Set<string>();
for (const header of form.value.headers) {
if (!header.name && !header.value) continue;
if (!/^[A-Za-z0-9-]{1,64}$/.test(header.name)) return "Header names may contain only letters, digits and dashes.";
if (header.value.includes("$")) return `${header.name} cannot contain $.`;
const key = header.name.toLowerCase();
if (seen.has(key)) return `${header.name} is listed twice.`;
seen.add(key);
}
return "";
});

Comment thread src/components/DomainFormModal.vue Outdated
proxy_timeout: form.value.proxy_timeout || undefined,
proxy_buffering: form.value.stream_responses ? false : undefined,
response_headers: responseHeaders(),
canonical_redirect: form.value.canonical_redirect ? "primary" : undefined,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The checkbox is hidden when no alias remains, but form.canonical_redirect keeps its value, so saving a domain whose aliases were all removed still writes canonical_redirect: "primary". Guard the payload with the same alias condition the v-if uses, otherwise the redirect silently applies when an alias is added later.

Suggested change
canonical_redirect: form.value.canonical_redirect ? "primary" : undefined,
canonical_redirect:
form.value.canonical_redirect && form.value.aliases.some((a) => a.trim()) ? "primary" : undefined,

nfebe added 2 commits October 26, 2026 20:26
The allow-list refuses addresses with out-of-range parts or prefixes
before the agent sees them, a header listed twice is refused instead of
one copy being dropped, and removing every alias also turns off the
alias redirect.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Deploying flatrun-ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4eb91ab
Status: ✅  Deploy successful!
Preview URL: https://943f8f97.flatrun-ui.pages.dev
Branch Preview URL: https://feat-proxy-tuning.flatrun-ui.pages.dev

View logs

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review complete. See the overview comment for a summary.

const IPV4 = new RegExp(`^${IPV4_OCTET}(\\.${IPV4_OCTET}){3}(\\/(3[0-2]|[12]?\\d))?$`);
const IPV6 = /^[0-9A-Fa-f:]*:[0-9A-Fa-f:]*(\/(12[0-8]|1[01]\d|[1-9]?\d))?$/;

function validIPv6(entry: string) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

filter(Boolean) hides empty groups, so malformed addresses such as :1:2:3:4:5:6:7:8 and ::: pass validIPv6 and are written into the allow-list, where nginx refuses the whole site config. Split on :: and validate every group instead of dropping empty ones.

Suggested change
function validIPv6(entry: string) {
function validIPv6(entry: string) {
if (!IPV6.test(entry)) return false;
const address = entry.split("/")[0];
const parts = address.split("::");
if (parts.length > 2) return false;
const sides = parts.map((part) => (part === "" ? [] : part.split(":")));
if (sides.some((side) => side.some((group) => !/^[0-9A-Fa-f]{1,4}$/.test(group)))) return false;
const groups = sides.reduce((count, side) => count + side.length, 0);
return parts.length === 2 ? groups <= 7 : groups === 8;
}

Base automatically changed from feat/upload-limit to main October 27, 2026 20:12
@nfebe
nfebe merged commit 0ba07d9 into main Oct 27, 2026
1 check passed
@nfebe
nfebe deleted the feat/proxy-tuning branch October 27, 2026 20:14
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.

1 participant