Skip to content

Commit

Permalink
Add comment about CORS in todos-lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
natanrolnik authored Oct 27, 2024
1 parent 22a7f6e commit 45cb1d1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions todos-lambda/Sources/App/lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@ struct AppLambda: APIGatewayLambdaFunction {
router.get("/") { _, _ in
return "Hello"
}

// When enabling Lambda function URLs, CORS can be configured at the AWS level, and there's
// no need for this middleware.
// If you prefer to manage CORS internally instead, use this:
router.add(middleware: CORSMiddleware(
allowOrigin: .originBased,
allowHeaders: [.contentType],
allowMethods: [.get, .options, .post, .delete, .patch]
))

TodoController(dynamoDB: dynamoDB, tableName: tableName).addRoutes(to: router.group("todos"))

return router.buildResponder()
Expand Down

0 comments on commit 45cb1d1

Please sign in to comment.