Kenny
06/07/2022, 10:31 AMsite.url
that's in the FrontendStack.
export function AuthApiStack({ stack, app }) {
const { bucket } = use(StorageStack);
const { table } = use(StorageStack); //This new ApiStack references the table resource from the StorageStack that we created previously.
const auth = new Auth(stack, "Auth", {
login: ["email"],
cdk: {
userPoolClient: {
supportedIdentityProviders: [
cognito.UserPoolClientIdentityProvider.GOOGLE,
cognito.UserPoolClientIdentityProvider.COGNITO,
],
oAuth: {
callbackUrls: [
app.stage === "prod"
? "<https://dfwwlqfwiq3c2.cloudfront.net/>"
: "<http://localhost:3000>",
],
logoutUrls: [
app.stage === "prod"
? "<https://dfwwlqfwiq3c2.cloudfront.net/>"
: "<http://localhost:3000>",
],
},
},
},
}); ...
I want to replace the cloudfront urls with site.url but this stack is in use buy the FrontendStack
export function FrontendStack({ stack, app }) {
const { auth, api, domain } = use(AuthApiStack);
const { bucket } = use(StorageStack);
const site = new ReactStaticSite(stack, "ReactSite", {
path: "frontend",
environment: {
REACT_APP_API_URL: api.customDomainUrl || api.url,
REACT_APP_REGION: app.region,
REACT_APP_BUCKET: bucket.bucketName,
REACT_APP_USER_POOL_ID: auth.userPoolId,
REACT_APP_IDENTITY_POOL_ID: auth.cognitoIdentityPoolId,
REACT_APP_USER_POOL_CLIENT_ID: auth.userPoolClientId,
REACT_APP_API_STAGE: app.stage,
REACT_APP_COGNITO_DOMAIN: domain.domainName,
},
});
stack.addOutputs({
SiteUrl: site.url,
});
}
My frontend React also needs SiteUrl but I cans easily pass it through the environment variables.Frank
Frank
Frank
Kenny
06/07/2022, 2:23 PMKenny
06/07/2022, 2:23 PMFrank
Frank
// FrontendStack
const site = new ReactStaticSite(..);
new ssm.StringParameter(stack, "SiteURL", {
parameterName: "SiteURL",
stringValue: site.url;
});
// AuthApiStack
const auth = new Auth(stack, "Auth", {
...,
callbackUrls: [
ssm.StringParameter.fromStringParameterAttributes(stack, "SiteURL", {
parameterName: "SiteURL",
}).stringValue
],
...,
});
Frank
Frank
Kenny
06/07/2022, 2:33 PMFrank
Kenny
06/07/2022, 2:35 PM