mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-01 20:55:16 +09:00
Every screen that asked for a domain had its own input: a copied regex in service settings, a separate "give it a subdomain" modal, a bare required field on the Domains page. DomainField offers a managed subdomain (label + base domain) or the user's own domain, normalizes what is pasted, and says what will happen with DNS before submit. attachDomain() sends either kind to the right endpoint. Service settings now has one add-domain flow instead of an attach form plus a subdomain modal, and the Domains page add modal uses the same field.
22 lines
760 B
JavaScript
22 lines
760 B
JavaScript
import api from './api';
|
|
|
|
/**
|
|
* Attach what a DomainField reported to an app. A managed subdomain goes
|
|
* through give-subdomain (vhost plus, in per-site mode, the DNS record); any
|
|
* other hostname becomes a plain domain row. Throws on failure; returns the
|
|
* API response.
|
|
*/
|
|
export async function attachDomain(applicationId, name, info, { isPrimary = false } = {}) {
|
|
if (info?.mode === 'subdomain') {
|
|
const res = await api.giveSubdomain(applicationId, info.label, info.base);
|
|
if (!res?.success) throw new Error(res?.error || 'Failed to publish subdomain');
|
|
return res;
|
|
}
|
|
return api.createDomain({
|
|
name,
|
|
application_id: applicationId,
|
|
is_primary: isPrimary,
|
|
ssl_enabled: false,
|
|
});
|
|
}
|