@@ -14,9 +14,9 @@ import {
1414import { Provider } from 'aws-cdk-lib/custom-resources' ;
1515import { Construct } from 'constructs' ;
1616import { CfnBranch } from 'aws-cdk-lib/aws-amplify' ;
17- import { IApp , Platform } from './app' ;
17+ import { App , IApp , Platform } from './app' ;
1818import { BasicAuth } from './basic-auth' ;
19- import { renderEnvironmentVariables } from './utils' ;
19+ import { renderEnvironmentVariables , isServerSideRendered } from './utils' ;
2020import { AssetDeploymentIsCompleteFunction , AssetDeploymentOnEventFunction } from '../custom-resource-handlers/dist/aws-amplify-alpha/asset-deployment-provider.generated' ;
2121import { addConstructMetadata , MethodMetadata } from 'aws-cdk-lib/core/lib/metadata-resource' ;
2222import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable' ;
@@ -194,11 +194,13 @@ export class Branch extends Resource implements IBranch {
194194 // Enhanced CDK Analytics Telemetry
195195 addConstructMetadata ( this , props ) ;
196196
197- const platform = props . app . platform ;
198- const isSSR = platform === Platform . WEB_COMPUTE || platform === Platform . WEB_DYNAMIC ;
197+ if ( props . app instanceof App ) {
198+ const platform = props . app . platform ;
199+ const isSSR = isServerSideRendered ( platform ) ;
199200
200- if ( props . computeRole && ! isSSR ) {
201- throw new ValidationError ( '`computeRole` can only be specified for branches of apps with `Platform.WEB_COMPUTE` or `Platform.WEB_DYNAMIC`.' , this ) ;
201+ if ( props . computeRole && ! isSSR ) {
202+ throw new ValidationError ( '`computeRole` can only be specified for branches of apps with `Platform.WEB_COMPUTE` or `Platform.WEB_DYNAMIC`.' , this ) ;
203+ }
202204 }
203205
204206 this . environmentVariables = props . environmentVariables || { } ;
0 commit comments