Ajax Proxy Plugin
Dependency:
compile "org.grails.plugins:ajax-proxy:0.1.1"
Summary
Ajax Proxy Plugin (for cross-domain requests)
Installation
grails install-plugin ajax-proxy
Description
Grails Ajax Proxy Plugin
Want to use some Ajax in your Grails application? Same Origin Policy getting in your way? Looking for a quick and easy solution?For example, say you want to use the Google Translate API but either don't want to use JSONP or can't because you need to translate strings that are too long to include in the URL as query parameters.Rungrails install-plugin ajax-proxy
grails-app/conf/Config.groovy
:plugins { proxy { proxyScheme = 'https://' proxyHost = 'www.googleapis.com' proxyPort = '443' proxyPath = '' } }
/proxy/language/translate/v2
/proxy
+ the path on the destination server)You're done.Notes
Grails will process (e.g. turn a POST into a GET) and swallow theX-HTTP-Method-Override
header. (It appears this is done by the HiddenHttpMethodFilter
.)To pass your forwarded requests through unchanged use X-Forward-HTTP-Method-Override
, which will be forwarded as X-HTTP-Method-Override
. (New in Version 0.1.2)