Skip to content

Commit

Permalink
docs: fix lambda-function-url example's HttpApi CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
brettstack committed Apr 14, 2024
1 parent d3f81b8 commit 09e951f
Showing 1 changed file with 6 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,36 +164,18 @@ export default class ExpressApi extends Construct {
})
}

const api = new HttpApi(this, 'HttpApi', {
apiName: `Todo-${getEnvironmentName(this.node)}`,
// corsPreflight: {
// allowHeaders: [
// // Must explicitly specify Authorization, othwerise maxAge isn't respected and preflight
// // will be sent on all requests https://twitter.com/annevk/status/1422959365846351875
// // Unfortunately, there appears to be a bug in API Gateway where it doesn't return the
// // correct preflight response headers when 'authorization' is defined.
// 'authorization',
// // '*',
// ],
// allowMethods: [CorsHttpMethod.ANY],
// allowOrigins: Cors.ALL_ORIGINS,
// maxAge: Duration.hours(24), // Firefox caps at 24 hours; Chromium caps at 2 hours
// },
defaultDomainMapping: domainResource
? {
domainName: domainResource,
}
: undefined,
})
const api = new HttpApi(this, 'HttpApi')
api.addRoutes({
path: '/{proxy+}',
integration,
authorizer,
// Must exclude OPTIONS so that CORS Preflight requests don't get sent through to Lambda,
// and instead are fulfilled by API Gateway
// methods: [HttpMethod.HEAD, HttpMethod.GET, HttpMethod.POST, HttpMethod.PATCH, HttpMethod.PUT, HttpMethod.DELETE],
methods: [HttpMethod.ANY],
})
api.addRoutes({
path: '/{proxy+}',
integration,
methods: [HttpMethod.OPTIONS],
})

// this.enableApiAccessLogs({ api })

Expand Down

0 comments on commit 09e951f

Please sign in to comment.