diff --git a/libs/adapters/src/blobStorage/s3.ts b/libs/adapters/src/blobStorage/s3.ts index 34dfb8db72c..8fa5621aa6e 100644 --- a/libs/adapters/src/blobStorage/s3.ts +++ b/libs/adapters/src/blobStorage/s3.ts @@ -1,6 +1,6 @@ import { CompleteMultipartUploadCommandOutput, S3 } from '@aws-sdk/client-s3'; import { BlobBucket, type BlobStorage } from '@hicommonwealth/core'; -import { S3_ASSET_BUCKET_CDN } from '@hicommonwealth/shared'; +import { PRODUCTION_DOMAIN, S3_ASSET_BUCKET_CDN } from '@hicommonwealth/shared'; import { config } from '../config'; import { exists_S3sdk, getSignedUrl_S3sdk, upload_S3sdk } from './util'; @@ -14,7 +14,7 @@ const s3Buckets: Partial> = : { assets: S3_ASSET_BUCKET_CDN, archives: 'outbox-event-stream-archive', - sitemap: 'sitemap.commonwealth.im', + sitemap: `sitemap.${PRODUCTION_DOMAIN}`, }; function formatS3Url( diff --git a/libs/shared/src/constants.ts b/libs/shared/src/constants.ts index 9663173d000..37840d9ecf9 100644 --- a/libs/shared/src/constants.ts +++ b/libs/shared/src/constants.ts @@ -22,6 +22,12 @@ export const DEFAULT_NAME = 'Anonymous'; export const MAX_RECIPIENTS_PER_WORKFLOW_TRIGGER = 1_000; +export const PRODUCTION_DOMAIN = 'common.xyz'; + +export const BLOG_SUBDOMAIN = `blog.${PRODUCTION_DOMAIN}`; + +export const DOCS_SUBDOMAIN = `docs.${PRODUCTION_DOMAIN}`; + export const S3_RAW_ASSET_BUCKET_DOMAIN = 's3.us-east-1.amazonaws.com/assets.commonwealth.im'; export const S3_ASSET_BUCKET_CDN = 'assets.commonwealth.im'; diff --git a/libs/sitemaps/src/createSitemapGenerator.ts b/libs/sitemaps/src/createSitemapGenerator.ts index 9a52fac0c27..86cead5a19c 100644 --- a/libs/sitemaps/src/createSitemapGenerator.ts +++ b/libs/sitemaps/src/createSitemapGenerator.ts @@ -2,6 +2,7 @@ import { blobStorage, logger } from '@hicommonwealth/core'; import { Paginator } from './createDatabasePaginator'; import { createSitemap } from './createSitemap'; import { createSitemapIndex } from './createSitemapIndex'; +import { rewriteURL } from './rewriteURL'; const log = logger(import.meta); @@ -20,6 +21,7 @@ export interface SitemapGenerator { export function createSitemapGenerator( paginators: ReadonlyArray, + hostname: string | undefined, ): SitemapGenerator { async function exec(): Promise { let idx = 0; @@ -44,8 +46,11 @@ export function createSitemapGenerator( content: sitemap, contentType: 'text/xml; charset=utf-8', }); - log.info(`Wrote sitemap: ${sitemapPath} to location ${res.url}`); - children.push({ location: res.url }); + + const url = rewriteURL(res.url, hostname); + + log.info(`Wrote sitemap: ${sitemapPath} to location ${url}`); + children.push({ location: url }); } } diff --git a/libs/sitemaps/src/rewriteURL.ts b/libs/sitemaps/src/rewriteURL.ts new file mode 100644 index 00000000000..fed342175e2 --- /dev/null +++ b/libs/sitemaps/src/rewriteURL.ts @@ -0,0 +1,12 @@ +/** + * AWS returns invalid URLs not the domain masked URL. + */ +export function rewriteURL(url: string, hostname: string | undefined): string { + if (!hostname) { + return url; + } + + const u = new URL(url); + u.hostname = hostname; + return u.toString(); +} diff --git a/libs/sitemaps/test/integration/createSitemapGenerator.spec.ts b/libs/sitemaps/test/integration/createSitemapGenerator.spec.ts index 344ab4052ba..49265b4889e 100644 --- a/libs/sitemaps/test/integration/createSitemapGenerator.spec.ts +++ b/libs/sitemaps/test/integration/createSitemapGenerator.spec.ts @@ -83,10 +83,10 @@ describe('createSitemapGenerator', { timeout: 10_000 }, function () { test('basic', async () => { const paginator = createDatabasePaginatorDefault(50); - const sitemapGenerator = createSitemapGenerator([ - paginator.threads, - paginator.profiles, - ]); + const sitemapGenerator = createSitemapGenerator( + [paginator.threads, paginator.profiles], + undefined, + ); const written = await sitemapGenerator.exec(); expect(inMemoryBlobs.size).to.equal(2); diff --git a/packages/commonwealth/client/public/robots.txt b/packages/commonwealth/client/public/robots.txt index 755fda7a58c..b4b7051815d 100644 --- a/packages/commonwealth/client/public/robots.txt +++ b/packages/commonwealth/client/public/robots.txt @@ -1,5 +1,5 @@ User-agent: * Disallow: /profile -Sitemap: https://sitemap.commonwealth.im/sitemap-index.xml +Sitemap: https://sitemap.common.xyz/sitemap-index.xml diff --git a/packages/commonwealth/deploy/environments/.env.public.commonwealthapp b/packages/commonwealth/deploy/environments/.env.public.commonwealthapp index 613ec3fbe40..5a0d0cdbc26 100644 --- a/packages/commonwealth/deploy/environments/.env.public.commonwealthapp +++ b/packages/commonwealth/deploy/environments/.env.public.commonwealthapp @@ -5,7 +5,7 @@ APP_ENV=production KNOCK_PUBLIC_API_KEY=pk_ynCCqD_rlxXTO0TvBCYUKYV5BSG5-vHoy451WGDHW5w KNOCK_IN_APP_FEED_ID=fc6e68e5-b7b9-49c1-8fab-6dd7e3510ffb NODE_ENV=production -SERVER_URL=https://commonwealth.im +SERVER_URL=https://common.xyz MAGIC_PUBLISHABLE_KEY=pk_live_B0604AA1B8EEFDB4 DISCORD_CLIENT_ID=1133050809412763719 SNAPSHOT_HUB_URL=https://hub.snapshot.org diff --git a/packages/commonwealth/scripts/sitemap-runner.ts b/packages/commonwealth/scripts/sitemap-runner.ts index 90639b243bb..c50ea77199e 100644 --- a/packages/commonwealth/scripts/sitemap-runner.ts +++ b/packages/commonwealth/scripts/sitemap-runner.ts @@ -1,5 +1,6 @@ import { HotShotsStats, S3BlobStorage } from '@hicommonwealth/adapters'; import { blobStorage, dispose, logger, stats } from '@hicommonwealth/core'; +import { PRODUCTION_DOMAIN } from '@hicommonwealth/shared'; import { createDatabasePaginatorDefault, createSitemapGenerator, @@ -33,10 +34,12 @@ async function doExec() { log.info('Creating paginator... '); const paginator = createDatabasePaginatorDefault(); - const { index } = await createSitemapGenerator([ - paginator.threads, - paginator.profiles, - ]).exec(); + const hostname = `sitemap.${PRODUCTION_DOMAIN}`; + + const { index } = await createSitemapGenerator( + [paginator.threads, paginator.profiles], + hostname, + ).exec(); log.info('Sitemap written to: ' + index.location); }