Skip to content

Commit 809449d

Browse files
authored
Fix preview warning page when inside iframe (#2373)
Signed-off-by: Bruno Grbavac <[email protected]>
1 parent 057beec commit 809449d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

apps/proxy/pkg/proxy/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func StartProxy(config *config.Config) error {
123123

124124
router.Any("/*path", func(ctx *gin.Context) {
125125
if ctx.Request.Method == "POST" && ctx.Request.URL.Path == ACCEPT_PREVIEW_PAGE_WARNING_PATH {
126-
handleAcceptProxyWarning(ctx, config.EnableTLS)
126+
handleAcceptProxyWarning(ctx, config.ProxyProtocol == "https")
127127
return
128128
}
129129

apps/proxy/pkg/proxy/warning_page.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ const (
2222
)
2323

2424
func handleAcceptProxyWarning(ctx *gin.Context, secure bool) {
25+
// Set SameSite attribute based on security context
26+
if secure {
27+
// For HTTPS, use SameSite=None to allow cross-origin iframe usage
28+
ctx.SetSameSite(http.SameSiteNoneMode)
29+
} else {
30+
// For HTTP (local dev), use SameSite=Lax
31+
ctx.SetSameSite(http.SameSiteLaxMode)
32+
}
33+
2534
// Set the acceptance cookie
2635
ctx.SetCookie(
2736
PREVIEW_PAGE_ACCEPT_COOKIE_NAME,

0 commit comments

Comments
 (0)