Skip to content

Commit

Permalink
feat: Configure CORS on CF
Browse files Browse the repository at this point in the history
  • Loading branch information
oliversalzburg committed Nov 24, 2023
1 parent b385a32 commit cb63f7a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/infra-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ permissions:
contents: read
id-token: write

concurrency:
group: infra-deploy
cancel-in-progress: true

jobs:
deploy:
environment:
Expand Down
34 changes: 33 additions & 1 deletion terraform/modules/kitten-science-website/cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,36 @@ resource "aws_cloudfront_distribution" "this" {
}

provider = aws.global
}
}

resource "cloudfront_response_headers_policy" "this" {
name = var.domain_name

cors_config {
access_control_allow_credentials = false

access_control_allow_headers {
items = [
"Accept",
"Accept-Language",
"Content-Language",
"Content-Type",
"Range"
]
}

access_control_allow_methods {
items = ["GET", "HEAD"]
}

access_control_allow_origins {
items = [
"https://kittensgame.com",
"http://127.0.0.1:8100",
"http://localhost:8100"
]
}

origin_override = true
}
}
2 changes: 1 addition & 1 deletion terraform/modules/kitten-science-website/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resource "aws_s3_bucket_public_access_block" "this" {
data "aws_iam_policy_document" "s3_public_read" {
statement {
principals {
type = "AWS"
type = "AWS"
identifiers = ["*"]
}

Expand Down

0 comments on commit cb63f7a

Please sign in to comment.