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

Do not render web console for non-HTML requests #317

Open
DanielHeath opened this issue Jun 9, 2022 · 5 comments
Open

Do not render web console for non-HTML requests #317

DanielHeath opened this issue Jun 9, 2022 · 5 comments

Comments

@DanielHeath
Copy link

If I get an error fetching some JSON in an XHR request, rendering web-console isn't going to help; I'm better off dropping into a debugger on the server process.

Any interest in adding merging a PR adding rails configuration setting like config.web_console.skip_request? = lambda {|request| request.xhr?}

@gsamokovarov
Copy link
Collaborator

Do you happen to render this JSON in a response with HTML media type? We really try to render the console only on HTML requests:

def acceptable_content_type?(headers)
headers["content-type"].to_s.include?("html")
end

@DanielHeath
Copy link
Author

That makes sense - I do have some HTML endpoints retrieved via xhr.

Perhaps also checking request.xhr? where you check acceptable_content_type? is worth doing? XHR handlers probably aren't equipped to deal with the web console.

Unfortunately this doesn't also work for the new fetch standard, since it doesn't set x-requested-with.

@gsamokovarov
Copy link
Collaborator

XHR requests are used in Turbo and I'm a bit reluctant to cut all of them off. Using Turbolinks or its newer incarnations is common for Rails projects.

@DanielHeath
Copy link
Author

Turbo uses fetch, not XHR: https://github.com/hotwired/turbo/blob/main/src/http/fetch_request.ts#L97 - and has done for at least 3 years.

@gsamokovarov
Copy link
Collaborator

Didn't realise that fetch requests don't get the XHR header. Let me think about it some more, as I'm reluctant to add yet another one-off config to Web Console.

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

No branches or pull requests

2 participants