Kristian Lake
03/23/2022, 12:39 AMFrank
// Create an Api
new sst.Api(this, "Api", {
customDomain: "<http://api.domain.com|api.domain.com>",
...
});
// Create a site
new sst.ReactStaticSite(this, "Site", {
customDomain: {
domainName: "<http://domain.com|domain.com>",
domainAlias: "<http://www.domain.com|www.domain.com>",
hostedZone: "<http://domain.com|domain.com>",
},
...
});
Frank
Kristian Lake
03/23/2022, 2:21 AM${scope.stage}.<http://oxydjinn.com|oxydjinn.com>
,
domainAlias: scope.stage === "prod" ? "www.oxydjinn.com" : undefined
},Kristian Lake
03/23/2022, 2:21 AMFrank
the reference problem
?Kristian Lake
03/23/2022, 2:31 AMKristian Lake
03/23/2022, 2:42 AMKristian Lake
03/23/2022, 2:43 AMFrank
Frank
Api
, specify hostedZone
like this
this.api = new sst.Api(this, "Api", {
customDomain: {
hostedZone: "<http://oxydjinn.com|oxydjinn.com>",
domainName:
scope.stage === "prod" ? "<http://api.oxydjinn.com|api.oxydjinn.com>" :
scope.stage === "dev" ? "<http://dev.api.oxydjinn.com|dev.api.oxydjinn.com>" :
scope.stage === "test" ? "<http://test.api.oxydjinn.com|test.api.oxydjinn.com>" :
scope.stage === "stage" ? "<http://stage.api.oxydjinn.com|stage.api.oxydjinn.com>" : undefined,
},
...
});
Frank
ReactStaticSite
, specify hostedZone
like this
const site = new sst.ReactStaticSite(this, "ReactSite", {
path: "frontend",
customDomain: {
hostedZone: "<http://oxydjinn.com|oxydjinn.com>",
domainName: scope.stage === "prod" ? "<http://oxydjinn.com|oxydjinn.com>" : `${scope.stage}.<http://oxydjinn.com|oxydjinn.com>`,
domainAlias: scope.stage === "prod" ? "<http://www.oxydjinn.com|www.oxydjinn.com>" : undefined
},
...
});
Kristian Lake
03/23/2022, 2:52 AMKristian Lake
03/23/2022, 2:57 AMKristian Lake
03/23/2022, 2:57 AMKristian Lake
03/23/2022, 2:57 AM${scope.stage}.<http://oxydjinn.com|oxydjinn.com>
,
domainAlias: scope.stage === "prod" ? "www.oxydjinn.com" : undefined
},
// customDomain: {
// domainName:
// scope.stage === "prod" ? "oxydjinn.com" : ${scope.stage}.<http://oxydjinn.com|oxydjinn.com>
,
// domainAlias: scope.stage === "prod" ? "www.oxydjinn.com" : undefined,
// hostedZone: "oxydjinn.com",
// },
// Pass in our environment variables
environment: {
REACT_APP_API_URL: api.customDomainUrl || api.url,
REACT_APP_REGION: scope.region,
REACT_APP_BUCKET: bucket.bucketName,
REACT_APP_USER_POOL_ID: auth.cognitoUserPool.userPoolId,
REACT_APP_IDENTITY_POOL_ID: auth.cognitoCfnIdentityPool.ref,
REACT_APP_USER_POOL_CLIENT_ID:
auth.cognitoUserPoolClient.userPoolClientId,
},
});
// Show the url in the output
this.addOutputs({
SiteUrl: site.customDomainUrl || site.url,
});
}
}Frank
Kristian Lake
03/23/2022, 3:00 AMKristian Lake
03/23/2022, 3:00 AMFrank
Kristian Lake
03/23/2022, 3:05 AMFrank
Kristian Lake
03/23/2022, 3:06 AMKristian Lake
03/23/2022, 3:06 AMFrank
npx sst deploy --stage prod
Kristian Lake
03/23/2022, 3:08 AMFrank
domainAlias
and deploy again?Kristian Lake
03/23/2022, 3:12 AMKristian Lake
03/23/2022, 3:17 AMKristian Lake
03/23/2022, 3:17 AMKristian Lake
03/23/2022, 3:20 AMKristian Lake
03/23/2022, 2:14 PMFrank