@@ -9,13 +9,13 @@ const {
99 configureDomainForBucket,
1010 configureBucketForRedirect
1111} = require ( './utils' )
12+ const regionUrls = require ( './awsRegionUrls' )
1213
1314/*
1415 * Website
1516 */
1617
1718class Website extends Component {
18-
1919 /**
2020 * Types
2121 */
@@ -102,7 +102,7 @@ class Website extends Component {
102102
103103 this . state . bucketName = inputs . bucketName
104104 this . state . region = inputs . region
105- this . state . url = `http://${ bucketOutputs . name } .s3-website- ${ inputs . region } .amazonaws.com `
105+ this . state . url = `http://${ bucketOutputs . name } .${ regionUrls [ inputs . region ] } `
106106 await this . save ( )
107107
108108 const outputs = {
@@ -112,20 +112,37 @@ class Website extends Component {
112112
113113 // Configure custom domain, if specified
114114 if ( inputs . domain ) {
115- const domain = await this . load ( '@serverless/ domain' )
115+ const domain = await this . load ( '@ublend-npm/serverless-compoonent- domain' )
116116 const subdomain = inputs . domain . split ( '.' ) [ 0 ]
117117 const secondLevelDomain = inputs . domain . replace ( `${ subdomain } .` , '' )
118118
119119 const domainInputs = {
120+ region : this . state . region ,
120121 domain : secondLevelDomain ,
121122 subdomains : { }
122123 }
123124
125+ // eslint-disable-next-line prefer-destructuring
126+ let cloudFront = inputs . cloudFront
127+ const { institution } = inputs
128+ if ( inputs . securityHeaders ) {
129+ cloudFront = {
130+ ...cloudFront ,
131+ customLambdaAssociations : [
132+ {
133+ functionName : `${ institution } -security-headers-injector-prod-injectSecurityHeaders` ,
134+ type : 'origin-response'
135+ }
136+ ]
137+ }
138+ }
139+
124140 domainInputs . subdomains [ subdomain ] = {
125141 url : this . state . url ,
126142 bucketName : this . state . bucketName ,
127- cloudFront : inputs . cloudFront
143+ cloudFront
128144 }
145+
129146 const domainOutputs = await domain ( domainInputs )
130147
131148 outputs . domain = domainOutputs . domains [ 0 ]
@@ -153,7 +170,7 @@ class Website extends Component {
153170 // Remove custom domain, if specified
154171 if ( this . state . domain ) {
155172 this . context . debug ( `Removing custom domain.` )
156- const domain = await this . load ( '@serverless/ domain' )
173+ const domain = await this . load ( '@ublend-npm/serverless-compoonent- domain' )
157174 await domain . remove ( )
158175 }
159176
0 commit comments