Grails links to js in https

I have developed a Javascript library that can be used on some of my other sites. This is a grails app. The Grails application can be accessed over HTTPS. However, there is a problem when linking to a JS file in HTTPS.

When including JS library, for example:

https://foo.my.domain/appcontext/static/js/myjslib.js

      

Grails redirects this request to:

http://foo.my.domain/appcontext/static/bundle-bundle_application_defer.js

      

Note HTTPS -> HTTP which raises "unsafe" warnings and js lib is blocked for example. chrome and IE.

If I refer to

https://foo.my.domain/appcontext/static/bundle-bundle_application_defer.js

      

it works great!

How can I get grails NOT to do this https -> http redirect when linking to static content?

+3


source to share


2 answers


Just use

<g:javascript src="myjslib.js" />. 

      

Js file should be in web-app / js folder



The documentation is here: http://grails.org/doc/latest/ref/Tags/javascript.html

Greetings

0


source


I had this problem too. We are including JS and CSS from a legacy app that was causing problems in Chrome.

In our case, we have an nginx proxy that does ssl encryption, so configuring Spring / Acegi was not an option. Below is a curl course (edited to get rid of server names / addresses) showing a redirect from https to http.

$ curl -v https://FOO.com/ess/js/framework/Widgets/Suggest.DropDown.js
* About to connect() to FOO.com port 443 (#0)
...
 GET /ess/js/framework/Widgets/Suggest.DropDown.js HTTP/1.1
...
 HTTP/1.1 302 Found
 Server: nginx/1.4.1
 Date: Fri, 31 May 2013 19:24:40 GMT
 Content-Length: 0
 Connection: keep-alive
 Location: http://FOO.com/ess/static/js/framework/Widgets/Suggest.DropDown.js

      



The solution I came across was to exclude deprecated resources from the resource plugin using the exception pattern in Config.groovy, for example:

grails.resources.adhoc.patterns = ['/images/*', '/css/*', '/js/*', '/plugins/*']
grails.resources.adhoc.excludes = [ '/css/framework/**', '/js/framework/**' ]

      

More documentation here: http://grails-plugins.github.io/grails-resources/guide/9.%20Configuration.html

0


source







All Articles