From e61b3515e68cbd045849a39270b60a500c1936e8 Mon Sep 17 00:00:00 2001 From: Ru Chern Chong Date: Wed, 14 Feb 2024 17:54:02 +0800 Subject: [PATCH] Migrate domain name --- cdk.context.json | 6 +++--- stacks/ApiStack.ts | 28 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/cdk.context.json b/cdk.context.json index 45c6f7c..31bfbe3 100644 --- a/cdk.context.json +++ b/cdk.context.json @@ -1,6 +1,6 @@ { - "hosted-zone:account=173188516302:domainName=ruchern.xyz:region=ap-southeast-1": { - "Id": "/hostedzone/Z03259131HBUFZWIXRJ0O", - "Name": "ruchern.xyz." + "hosted-zone:account=173188516302:domainName=sgmotortrends.com:region=ap-southeast-1": { + "Id": "/hostedzone/Z028295527IED1A8GMZIH", + "Name": "sgmotortrends.com." } } diff --git a/stacks/ApiStack.ts b/stacks/ApiStack.ts index c861a69..9ca0fdb 100644 --- a/stacks/ApiStack.ts +++ b/stacks/ApiStack.ts @@ -1,24 +1,36 @@ -import { Config, StackContext, Api, Cron } from "sst/constructs"; +import { + Config, + StackContext, + Api, + Cron, + ApiDomainProps, + ApiCorsProps, +} from "sst/constructs"; -const CUSTOM_DOMAINS: Record = { +const DOMAIN: string = "sgmotortrends.com"; +const SITE_URL: string = `https://${DOMAIN}`; +const DEV_API_DOMAIN: string = `dev.api.${DOMAIN}`; +const PROD_API_DOMAIN: string = `api.${DOMAIN}`; + +const CUSTOM_DOMAINS: Record = { dev: { - domainName: "dev.api.singapore-ev-trends.ruchern.xyz", - hostedZone: "ruchern.xyz", + domainName: DEV_API_DOMAIN, + hostedZone: DOMAIN, }, prod: { - domainName: "api.singapore-ev-trends.ruchern.xyz", - hostedZone: "ruchern.xyz", + domainName: PROD_API_DOMAIN, + hostedZone: DOMAIN, }, }; -const CORS_SETTINGS: Record = { +const CORS_SETTINGS: Record = { dev: { allowMethods: ["GET"], allowOrigins: ["*"], }, prod: { allowMethods: ["GET"], - allowOrigins: ["https://singapore-ev-trends.ruchern.xyz"], + allowOrigins: [SITE_URL], }, };