Last active
August 29, 2015 14:05
-
-
Save gingerlime/18f1a64a4c2a252ca766 to your computer and use it in GitHub Desktop.
Potential fix for http://stackoverflow.com/questions/25274125/jsonparsererror-n-unexpected-token-at-alihackeval-request-alihack-c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.middleware.insert_before ActionDispatch::ParamsParser, ::Rack::Robustness do |g| | |
g.no_catch_all | |
# you might need to replace this with JSON::ParserError, depending on your Rails configuration | |
# or you can catch both... | |
g.on(MultiJson::ParseError) { |ex| 400 } | |
g.content_type 'text/plain' | |
g.body{ |ex| ex.message } | |
g.ensure(true) do |ex| | |
env['rack.errors'].write(ex.message) | |
logger.warn(ex.message) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I changed
to
Thanks for sharing this fix! Initial test would at least get rid of this pesky alihack requests.