0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(core): fix url resolver for cloudflare (#3948)

This commit is contained in:
wangsijie 2023-06-02 11:42:48 +08:00 committed by GitHub
parent 44e18c081a
commit f35d1cbb86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,5 @@
import path from 'node:path';
import { type HostnameProviderData, cloudflareDataGuard } from '@logto/schemas';
import { got } from 'got';
@ -17,7 +19,9 @@ export const createCustomHostname = async (auth: HostnameProviderData, hostname:
return mockCustomHostnameResponse();
}
const response = await got.post(new URL(baseUrl, `/zones/${auth.zoneId}/custom_hostnames`), {
const response = await got.post(
new URL(path.join(baseUrl.pathname, `/zones/${auth.zoneId}/custom_hostnames`), baseUrl),
{
headers: {
Authorization: `Bearer ${auth.apiToken}`,
},
@ -25,7 +29,8 @@ export const createCustomHostname = async (auth: HostnameProviderData, hostname:
hostname,
ssl: { method: 'txt', type: 'dv', settings: { min_tls_version: '1.0' } },
},
});
}
);
assertThat(response.ok, 'domain.cloudflare_unknown_error');
@ -47,7 +52,10 @@ export const getCustomHostname = async (auth: HostnameProviderData, identifier:
}
const response = await got.get(
new URL(baseUrl, `/zones/${auth.zoneId}/custom_hostnames/${identifier}`),
new URL(
path.join(baseUrl.pathname, `/zones/${auth.zoneId}/custom_hostnames/${identifier}`),
baseUrl
),
{
headers: {
Authorization: `Bearer ${auth.apiToken}`,