X-Frame-Options is an HTTP response header that helps protect a web API from clickjacking by controlling which sources may load its pages inside FRAME or IFRAME elements. section 12.1.4
Add the header in Program.cs with the other HTTP security headers. The shown configuration runs outside development and sets the value to sameorigin, allowing framing only from the same origin. section 12.1.4
Configure the response header
Inside the production branch, add middleware that appends context.Response.Headers.Add("X-Frame-Options", "sameorigin"). Keep it alongside HSTS, X-XSS-Protection, X-Content-Type-Options, Content-Security-Policy, and Referrer-Policy settings.
