Search code examples
emailgrails

Resource plugin not rendering correctly with https


I'm attempting to use groovyPageRenderer.render() to render a temple with a model, so that I can email this rendered HTML using sendMail {}. Some of the banners we have include images and we add them using something like:

${resource(dir: 'images/email', file: 'background_body.gif', absolute: true)}

This is all good, and works fine in development. However, we wish to run the application over https, and despite setting grails.serverURL to "https://ourwebsite.com" (as indicated by the docs for Closure resource in ApplicationTagLib.groovy [from the grails-plugin-gsp]), it still tries to render the resources as available via http (which isn't available), only via https.


Solution

  • Based on this comment from the Resources plugin source, it appears that the plugin's resource() tag doesn't correctly support the attr absolute. If you're running Grails v2.0 or above, Grails' LinkGenerator may be a workaround. It's injected as grailsLinkGenerator, and can be invoked this way: grailsLinkGenerator.resource(dir: '...', file: '...', absolute: true)