Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to overwrite X-Frame-Options to allow for frames #258

Closed
jacknojo opened this issue Apr 15, 2023 · 3 comments
Closed

Not possible to overwrite X-Frame-Options to allow for frames #258

jacknojo opened this issue Apr 15, 2023 · 3 comments

Comments

@jacknojo
Copy link

Hi.

I am completely new to web development so perhaps there is some other way to solve this issue.

I have two routes

  • "/" which contains an iframe pointing to the other route:
  • "/form".

When loading this in my browser I am told that the "/form" content cannot be viewed. This is due to it having "X-Frame-Options: DENY".

I have tried, in the response r of the "/form" route to Dream.set_header r "X-Frame-Options" "SAMEORIGIN" but this results in two X-Frame-Options being sent, one with SAMEORIGIN and one with DENY.

Is there some way to solving this issue?

Thanks for a cool library!

@aantron
Copy link
Owner

aantron commented Apr 15, 2023

In my recollection, Dream doesn't set X-Frame-Options by default. We had issues about that and some other headers (#48, #49), but I decided that it's best to document how to use X-Frame-Options and let the developer make the choice to use it or not, since these techniques are highly situational, incomplete, interfere with development, and the risks are also handled by other means. This resulted in the example w-content-security-policy.

I just checked by running the example 2-middleware, and the only headers it sets by default are

Content-Length: 20
Content-Type: text/html; charset=utf-8

Are you, by any chance, doing something more complex, and/or running Dream behind a reverse proxy server that might be adding headers?

@jacknojo
Copy link
Author

I don't know why I didn't think of that. It was indeed nginx adding this header.

I have added add_header Content-Security-Policy "frame-ancestors example.com"; to my nginx configuration file and things are now working.

Thank you.

@aantron
Copy link
Owner

aantron commented Apr 16, 2023

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants