Let baseDomain be configured for Cloudflare and Deno Deploy

This commit is contained in:
Alex Gleason committed 2025-12-04 00:17:11 -06:00
1 parent bbb4a2534b
commit 2096c83b3c
9 files changed
+64 -7

No files matched your search

+4
View File
@@ -272,6 +272,7 @@ export function DeployDialog({ projectId, projectName, open, onOpenChange }: Dep
apiKey: cloudflareProvider.apiKey,
accountId: cloudflareProvider.accountId,
baseURL: cloudflareProvider.baseURL,
baseDomain: cloudflareProvider.baseDomain,
projectName: cloudflareForm.projectName || undefined,
corsProxy: cloudflareProvider.proxy ? config.corsProxy : undefined,
});
@@ -288,6 +289,7 @@ export function DeployDialog({ projectId, projectName, open, onOpenChange }: Dep
fs,
apiKey: denoProvider.apiKey,
organizationId: denoProvider.organizationId,
baseDomain: denoProvider.baseDomain,
baseURL: denoProvider.baseURL,
projectName: denoDeployForm.projectName || undefined,
corsProxy: denoProvider.proxy ? config.corsProxy : undefined,
@@ -469,6 +471,7 @@ export function DeployDialog({ projectId, projectName, open, onOpenChange }: Dep
apiKey={cloudflareProvider.apiKey}
accountId={cloudflareProvider.accountId}
baseURL={cloudflareProvider.baseURL}
baseDomain={cloudflareProvider.baseDomain}
projectId={projectId}
projectName={projectName}
savedProjectName={savedProjectName}
@@ -488,6 +491,7 @@ export function DeployDialog({ projectId, projectName, open, onOpenChange }: Dep
apiKey={denoProvider.apiKey}
organizationId={denoProvider.organizationId}
baseURL={denoProvider.baseURL}
baseDomain={denoProvider.baseDomain}
projectId={projectId}
projectName={projectName}
savedProjectName={savedProjectName}
@@ -27,6 +27,7 @@ interface CloudflareDeployFormProps {
apiKey: string;
accountId: string;
baseURL?: string;
baseDomain?: string;
projectId: string;
projectName?: string;
savedProjectName?: string;
@@ -38,6 +39,7 @@ export function CloudflareDeployForm({
apiKey,
accountId,
baseURL = 'https://api.cloudflare.com/client/v4',
baseDomain = 'workers.dev',
projectId,
projectName,
savedProjectName,
@@ -136,9 +138,9 @@ export function CloudflareDeployForm({
// Construct the URL preview
const getWorkerUrl = (scriptName: string) => {
if (workersSubdomain) {
return `https://${scriptName}.${workersSubdomain}.workers.dev`;
return `https://${scriptName}.${workersSubdomain}.${baseDomain}`;
}
return `https://${scriptName}.<subdomain>.workers.dev`;
return `https://${scriptName}.<subdomain>.${baseDomain}`;
};
return (
+3 -1
View File
@@ -25,6 +25,7 @@ interface DenoDeployFormProps {
apiKey: string;
organizationId: string;
baseURL?: string;
baseDomain?: string;
projectId: string;
projectName?: string;
savedProjectName?: string;
@@ -36,6 +37,7 @@ export function DenoDeployForm({
apiKey,
organizationId,
baseURL = 'https://api.deno.com/v1',
baseDomain = 'deno.dev',
projectId,
projectName,
savedProjectName,
@@ -117,7 +119,7 @@ export function DenoDeployForm({
// Construct the URL preview
const getProjectUrl = (name: string) => {
return `https://${name}.deno.dev`;
return `https://${name}.${baseDomain}`;
};
return (
+2
View File
@@ -37,6 +37,7 @@ export interface CloudflareProvider extends BaseDeployProvider {
apiKey: string;
accountId: string;
baseURL?: string;
baseDomain?: string;
proxy?: boolean;
}
@@ -45,6 +46,7 @@ export interface DenoDeployProvider extends BaseDeployProvider {
apiKey: string;
organizationId: string;
baseURL?: string;
baseDomain?: string;
proxy?: boolean;
}
+2
View File
@@ -111,6 +111,7 @@ const cloudflareProviderSchema = baseDeployProviderSchema.extend({
apiKey: z.string(),
accountId: z.string(),
baseURL: z.string().optional(),
baseDomain: z.string().optional(),
});
const denoDeployProviderSchema = baseDeployProviderSchema.extend({
@@ -118,6 +119,7 @@ const denoDeployProviderSchema = baseDeployProviderSchema.extend({
apiKey: z.string(),
organizationId: z.string(),
baseURL: z.string().optional(),
baseDomain: z.string().optional(),
});
const deployProviderSchema: z.ZodType<DeployProvider> = z.discriminatedUnion('type', [
+5 -3
View File
@@ -46,6 +46,7 @@ export class CloudflareAdapter implements DeployAdapter {
private apiKey: string;
private accountId: string;
private baseURL: string;
private baseDomain: string;
private projectName?: string;
private corsProxy?: string;
@@ -54,6 +55,7 @@ export class CloudflareAdapter implements DeployAdapter {
this.apiKey = config.apiKey;
this.accountId = config.accountId;
this.baseURL = config.baseURL || 'https://api.cloudflare.com/client/v4';
this.baseDomain = config.baseDomain || 'workers.dev';
this.projectName = config.projectName;
this.corsProxy = config.corsProxy;
}
@@ -118,11 +120,11 @@ export class CloudflareAdapter implements DeployAdapter {
// Step 5: Enable the workers.dev subdomain for this script
await this.enableWorkersDevSubdomain(scriptName);
// Step 6: Get the account's workers.dev subdomain
// Step 6: Get the account's workers subdomain
const subdomain = await this.getWorkersSubdomain();
// Construct the URL
const workerUrl = `https://${scriptName}.${subdomain}.workers.dev`;
// Construct the URL using the configurable base domain
const workerUrl = `https://${scriptName}.${subdomain}.${this.baseDomain}`;
return {
url: workerUrl,
+3 -1
View File
@@ -33,6 +33,7 @@ export class DenoDeployAdapter implements DeployAdapter {
private apiKey: string;
private organizationId: string;
private baseURL: string;
private baseDomain: string;
private projectName?: string;
private corsProxy?: string;
@@ -41,6 +42,7 @@ export class DenoDeployAdapter implements DeployAdapter {
this.apiKey = config.apiKey;
this.organizationId = config.organizationId;
this.baseURL = config.baseURL || 'https://api.deno.com/v1';
this.baseDomain = config.baseDomain || 'deno.dev';
this.projectName = config.projectName;
this.corsProxy = config.corsProxy;
}
@@ -66,7 +68,7 @@ export class DenoDeployAdapter implements DeployAdapter {
await this.collectFiles(distPath, '', assets);
// Step 3: Create deployment with assets and domain
const domain = `${project.name}.deno.dev`;
const domain = `${project.name}.${this.baseDomain}`;
const deployment = await this.createDeployment(project.id, assets, domain);
return {
+2
View File
@@ -60,6 +60,7 @@ export interface CloudflareDeployConfig {
apiKey: string;
accountId: string;
baseURL?: string;
baseDomain?: string;
projectName?: string;
corsProxy?: string;
}
@@ -69,6 +70,7 @@ export interface DenoDeployConfig {
apiKey: string;
organizationId: string;
baseURL?: string;
baseDomain?: string;
projectName?: string;
corsProxy?: string;
}
+39
View File
@@ -265,6 +265,24 @@ function SortableProviderItem({ provider, index, preset, onRemove, onUpdate, sho
}}
/>
</div>
{(provider.type === 'cloudflare' || provider.type === 'deno') && (
<div className="grid gap-2">
<Label htmlFor={`provider-${index}-baseDomain`}>
Base Domain (Optional)
</Label>
<Input
id={`provider-${index}-baseDomain`}
placeholder={provider.type === 'cloudflare' ? 'workers.dev' : 'deno.dev'}
value={provider.baseDomain || ''}
onChange={(e) => onUpdate(index, { ...provider, baseDomain: e.target.value })}
/>
<p className="text-xs text-muted-foreground">
{provider.type === 'cloudflare'
? 'The domain suffix for deployed workers (e.g., workers.dev)'
: 'The domain suffix for deployed projects (e.g., deno.dev)'}
</p>
</div>
)}
<div className="flex items-center space-x-2">
<Checkbox
id={`provider-${index}-proxy`}
@@ -424,6 +442,7 @@ export function DeploySettings() {
const [customAccountId, setCustomAccountId] = useState('');
const [customOrganizationId, setCustomOrganizationId] = useState('');
const [customBaseURL, setCustomBaseURL] = useState('');
const [customBaseDomain, setCustomBaseDomain] = useState('');
const [customHost, setCustomHost] = useState('');
const [customProxy, setCustomProxy] = useState(false);
const [customGateway, setCustomGateway] = useState('');
@@ -601,6 +620,7 @@ export function DeploySettings() {
apiKey: customApiKey.trim(),
accountId: customAccountId.trim(),
...(customBaseURL?.trim() && { baseURL: customBaseURL.trim() }),
...(customBaseDomain?.trim() && { baseDomain: customBaseDomain.trim() }),
...(customProxy && { proxy: true }),
};
} else if (customProviderType === 'deno') {
@@ -612,6 +632,7 @@ export function DeploySettings() {
apiKey: customApiKey.trim(),
organizationId: customOrganizationId.trim(),
...(customBaseURL?.trim() && { baseURL: customBaseURL.trim() }),
...(customBaseDomain?.trim() && { baseDomain: customBaseDomain.trim() }),
...(customProxy && { proxy: true }),
};
} else {
@@ -627,6 +648,7 @@ export function DeploySettings() {
setCustomAccountId('');
setCustomOrganizationId('');
setCustomBaseURL('');
setCustomBaseDomain('');
setCustomHost('');
setCustomProxy(false);
};
@@ -963,6 +985,7 @@ export function DeploySettings() {
setCustomAccountId('');
setCustomOrganizationId('');
setCustomBaseURL('');
setCustomBaseDomain('');
setCustomHost('');
setCustomProxy(false);
setCustomGateway('');
@@ -1105,6 +1128,22 @@ export function DeploySettings() {
onChange={(e) => setCustomBaseURL(e.target.value)}
/>
</div>
{(customProviderType === 'cloudflare' || customProviderType === 'deno') && (
<div className="grid gap-2">
<Label htmlFor="custom-basedomain">Base Domain (Optional)</Label>
<Input
id="custom-basedomain"
placeholder={customProviderType === 'cloudflare' ? 'workers.dev' : 'deno.dev'}
value={customBaseDomain}
onChange={(e) => setCustomBaseDomain(e.target.value)}
/>
<p className="text-xs text-muted-foreground">
{customProviderType === 'cloudflare'
? 'The domain suffix for deployed workers (e.g., workers.dev)'
: 'The domain suffix for deployed projects (e.g., deno.dev)'}
</p>
</div>
)}
</>
)}