@@ -25,41 +25,13 @@ locals {
2525# Cache / origin-request policies
2626# ---------------------------------------------------------------------------
2727
28- # Forward the viewer Host header so Intercode can resolve the convention .
29- resource "aws_cloudfront_origin_request_policy" "forward_host " {
30- name = " ${ var . name } -forward-host "
28+ # Forward all viewer headers, cookies, and query strings to the Rails origin .
29+ resource "aws_cloudfront_origin_request_policy" "forward_all " {
30+ name = " ${ var . name } -forward-all "
3131
32- cookies_config { cookie_behavior = " none" }
33- query_strings_config { query_string_behavior = " none" }
34-
35- headers_config {
36- header_behavior = " whitelist"
37- headers {
38- items = [" Host" ]
39- }
40- }
41- }
42-
43- # Like forward_host, but also passes the HttpOnly refresh-token cookie so
44- # /oauth_session/* endpoints can read it on the Rails side.
45- resource "aws_cloudfront_origin_request_policy" "forward_host_with_refresh_cookie" {
46- name = " ${ var . name } -forward-host-refresh-cookie"
47-
48- cookies_config {
49- cookie_behavior = " whitelist"
50- cookies {
51- items = [" __Host-intercode_refresh" ]
52- }
53- }
54-
55- query_strings_config { query_string_behavior = " none" }
56-
57- headers_config {
58- header_behavior = " whitelist"
59- headers {
60- items = [" Host" ]
61- }
62- }
32+ cookies_config { cookie_behavior = " allViewer" }
33+ query_strings_config { query_string_behavior = " allViewer" }
34+ headers_config { header_behavior = " allViewer" }
6335}
6436
6537# /og-shell: forward Host + the `path` query param so each path caches
@@ -205,7 +177,7 @@ resource "aws_cloudfront_distribution" "this" {
205177 cached_methods = [" GET" , " HEAD" ]
206178 compress = true
207179 cache_policy_id = aws_cloudfront_cache_policy. no_cache . id
208- origin_request_policy_id = aws_cloudfront_origin_request_policy. forward_host_with_refresh_cookie . id
180+ origin_request_policy_id = aws_cloudfront_origin_request_policy. forward_all . id
209181 viewer_protocol_policy = " redirect-to-https"
210182 }
211183
@@ -242,7 +214,7 @@ resource "aws_cloudfront_distribution" "this" {
242214 cached_methods = [" GET" , " HEAD" ]
243215 compress = true
244216 cache_policy_id = aws_cloudfront_cache_policy. no_cache . id
245- origin_request_policy_id = aws_cloudfront_origin_request_policy. forward_host . id
217+ origin_request_policy_id = aws_cloudfront_origin_request_policy. forward_all . id
246218 viewer_protocol_policy = " redirect-to-https"
247219 }
248220 }
@@ -255,7 +227,7 @@ resource "aws_cloudfront_distribution" "this" {
255227 cached_methods = [" GET" , " HEAD" ]
256228 compress = true
257229 cache_policy_id = aws_cloudfront_cache_policy. cdn_spa_shell . id
258- origin_request_policy_id = aws_cloudfront_origin_request_policy. forward_host . id
230+ origin_request_policy_id = aws_cloudfront_origin_request_policy. forward_all . id
259231 viewer_protocol_policy = " redirect-to-https"
260232 }
261233
@@ -278,7 +250,7 @@ resource "aws_cloudfront_distribution" "this" {
278250 cached_methods = [" GET" , " HEAD" ]
279251 compress = true
280252 cache_policy_id = aws_cloudfront_cache_policy. cdn_spa_shell . id
281- origin_request_policy_id = aws_cloudfront_origin_request_policy. forward_host . id
253+ origin_request_policy_id = aws_cloudfront_origin_request_policy. forward_all . id
282254 viewer_protocol_policy = " redirect-to-https"
283255
284256 lambda_function_association {
0 commit comments