File tree 2 files changed +20
-2
lines changed
infrastructure/lib/stacks
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -165,9 +165,27 @@ export class EmailStack extends cdk.Stack {
165
165
const contact = this . api . root . addResource ( "contact" ) ;
166
166
contact . addMethod (
167
167
"POST" ,
168
- new apigateway . LambdaIntegration ( this . emailFunction )
168
+ new apigateway . LambdaIntegration ( this . emailFunction ) ,
169
+ {
170
+ authorizationType : apigateway . AuthorizationType . NONE , // Allow unauthenticated access
171
+ apiKeyRequired : false ,
172
+ }
169
173
) ;
170
174
175
+ // Add CORS options to the API
176
+ const corsOptions : apigateway . CorsOptions = {
177
+ allowOrigins : [
178
+ `https://${ props . domainName } ` ,
179
+ `https://www.${ props . domainName } ` ,
180
+ process . env . ALLOWED_ORIGIN ! ,
181
+ ] ,
182
+ allowMethods : [ 'POST' , 'OPTIONS' ] ,
183
+ allowHeaders : [ 'Content-Type' ] ,
184
+ } ;
185
+
186
+ // Apply CORS to the contact resource
187
+ contact . addCorsPreflight ( corsOptions ) ;
188
+
171
189
// Create custom policy for SES permissions
172
190
const sesPolicy = new iam . PolicyStatement ( {
173
191
effect : iam . Effect . ALLOW ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " bjornmelin-platform-io" ,
3
- "version" : " 0.1.0 " ,
3
+ "version" : " 0.1.1 " ,
4
4
"private" : true ,
5
5
"scripts" : {
6
6
"dev" : " next dev" ,
You can’t perform that action at this time.
0 commit comments