Answer the question
In order to leave comments, you need to log in
How to display a Rails application page inside an iframe?
I need to display my page which is part of an application on another page of that application inside an iframe
For example. I have page /customers
and page /invoices
(both actions are #index
). On the page /invoices
there is How iframe
to src = 'http://localhost:3000/customers'
make it work correctly (and in the production environment too, i.e. example.com/invoices
should display example.com/customer
inside iframe
)?
I already tried various solutions from StackOverflow:
Response.headers.delete ('X-Frame-Options')
inside CustomerController#index
(and before_action
, and after_action
, and right inside the action)config.action_dispatch.default_headers = {'X-Frame-Options' => 'ALLOWALL'}
ApplicationController
as inCustomerController
response.headers ['X-Frame-Options'] = 'ALLOWALL'
localhost refused to connect
in Chrome and Firefox Can’t Open This Page
in Firefox. iframe src = '/customers'
Answer the question
In order to leave comments, you need to log in
As a result, the problem was that in the header of the http request, the rails added frame-ancestors: 'none'
Climbed into the config and changed
SecureHeaders::Configuration.default do |config|
config.csp = {
...
frame_ancestors: %w['self'], # Replaced from frame_ancestors: %w['none'],
...
}
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question