Skip to content

Commit

Permalink
Merge pull request #120 from ChallengeClub/bug/cloudfront-redirect
Browse files Browse the repository at this point in the history
cloudfront functionの追加 subpageへのアクセスをrootにリダイレクト
  • Loading branch information
EndoNrak authored Oct 21, 2023
2 parents 832f8f2 + 1477e8f commit 0bbe776
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'router.dart' as Router;

Future main() async {
// setUrlStrategy(PathUrlStrategy());
setUrlStrategy(PathUrlStrategy());
// パスベースのURLストラテジーを設定 これがないと、authのリダイレクト時にhttps://hogehoge/#/にリダイレクトされてしまって認可コードを取得できない
runApp(
ProviderScope(
Expand Down
12 changes: 12 additions & 0 deletions terraform/resources/cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ resource "aws_cloudfront_distribution" "tetris-hosting-cloudfront" {
default_ttl = 3600
max_ttl = 86400
}

# without this, requests to subpage requests (like "/page") directory goes to origin s3 bucket
# 404 error would be thrown by s3, because the bucket doesn't have such a file or folder
# resulting in cloudfront originated 403 response for client
custom_error_response {
error_caching_min_ttl = 86400
error_code = 403
response_code = 200
response_page_path = "/"
}

restrictions {
geo_restriction {
Expand All @@ -42,6 +52,8 @@ resource "aws_cloudfront_distribution" "tetris-hosting-cloudfront" {
ssl_support_method = "sni-only"
minimum_protocol_version = "TLSv1.2_2021"
}


}

resource "aws_cloudfront_origin_access_identity" "tetris-hosting" {}

0 comments on commit 0bbe776

Please sign in to comment.