rails app(web) 嵌入到 iframe 中
ruby on rails 的 web 預設是無法嵌入到 HTML iframe 中的,本篇文章將教學如何使其成功在不同網域中將 rails web 成功嵌入到 iframe 中。

假設我的 ruby on rails web 的 domain 為 example.localhost,當我想要在 foo.localhost 中嵌入 iframe 連到 example.localhost 時,會獲得以下錯誤訊息:
Refused to display 'example.localhost'; in a frame because it set 'X-Frame-Options' to 'sameorigin'.
這是因為 rails 預設 response 的 http headers 中,X-Frame-Options 的值為 sameorigin。
查詢 X-Frame-Options 的 MDN 文件,其值只有 sameorigin 或 deny 兩種。
因此解決辦法為,直接在 rails 端刪掉 X-Frame-Options。
# xxx_controller.rb
response.headers.delete 'X-Frame-Options'
另外,從 MDN 文件中可知 X-Frame-Options 在未來將會停用。
取而代之的是在 http headers 中的 Content-Security-Policy 加入 frame-ancestors 相關參數。
延伸閱讀
加入 BNI 商會心得
於 2023/10 加入了 BNI 台南商會(大信白金),本篇文章將分享加入後的心得,並持續更新心得內容,確認在不同階段的自己是否有偏離初衷。
設定電子郵件 DMARC
提供設定 DMARC 的範例,並且提供官方語法說明和檢測工具連結。
設定電子郵件 DKIM
以 AWS SES 和 Gmail 為例,說明如何設定 DKIM,並且提供相關檢測工具。DKIM 除了需要透過 DNS TXT 設定完,需要先申請好簽署用的金鑰。

