I am trying to allow others embed pages from my rails app on many websites. I can get it to work in Chrome and Firefox using X-Frame-Options. Is there a content security policy that is equivalent
response.headers['X-Frame-Options'] = "ALLOW-FROM *"
Here is the bit using X-Frame-Options
class PeopleController < ApplicationController
def embed
response.headers['X-Frame-Options'] = "ALLOW-FROM *"
@company = People.new
end
end
But does not work, when using content security policy in both Chrome and Google when i use content security policy
class PeopleController < ApplicationController
content_security_policy do |p|
p.frame_ancestors "self", "*"
end
def embed
@company = People.new
end
end
When using Content Security Policy, it throws this error:
Refused to frame 'http://localhost:3000/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors self".
and this is an example of the embed code:
<iframe src="http://localhost:3000/people/embed"></iframe>
and this is another one I tried:
<iframe src="/people/embed"></iframe>
Update
With content-security policy, this works only on Firefox:
content_security_policy do |p|
p.frame_ancestors 'self', "*"
end