I've tried several things:
just using the url:
resource url: '//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css', disposition: 'head'
local url with linkOverride:
resource url: '/lib/bootstrap/css/bootstrap.min.css', linkOverride: '//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css', disposition: 'head'
using the baseurl mapper config:
grails.resources.mappers.baseurl.modules = [
core: "//netdna.bootstrapcdn.com/"
]
resource url: 'bootstrap/3.0.0/css/bootstrap.min.css', disposition: 'head'
None of these work. I always get some form of
Resource not found:
//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css
Any help is appreciated.
Co-incidentally I am working on it right now as I see the question.
Looks like we have to explicitly use http for the CDN url.
resource url: 'http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css'
Same goes with linkOverride.
Related
I have a service with this path http://myhost.com/v2/1234/brand/order/issues/123 that needs to send the actual call to http://anotherhost.com/issues/123.
If I want to avoid the solution to write a ZuulFilter
Is there a way, with the configuration to say: the prefix is /v2/*/*/order/issues and just use 123?
zuul:
routes:
test2:
path: /v2/*/*/orders/issues/**
url: http://anotherhost.com/issues/
stripPrefix: true
No, there's no way to configure such behaviour. You need to create custom ZuulFilter
By default Zuul will only strip prefixes that do not contain special characters. e.g.
zuul:
routes:
test1:
path: /orders/** <--- '/orders' is stripped
url: http://anotherhost.com/issues/
test2:
path: /*/orders/** <--- nothing is stripped
url: http://anotherhost.com/issues/
I'm not clear on how to configure my applicationResources.groovy to use CDN for resources. My file looks like:
core {
dependsOn 'jquery'
// <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
resource url:'http://localhost/js/jquery.ui.touch-punch.min.js'
resource url:'http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js'
resource url:'http://localhost/js/modernizr.js'
resource url:'http://localhost/js/bootbox.min.js'
resource url:'http://localhost/js/flatui-checkbox.js'
resource url:'http://localhost/js/flatui-radio.js'
resource url:'http://localhost/js/jquery.tagsinput.js'
resource url:'http://localhost/js/jquery.placeholder.js'
resource url:'http://localhost/js/util.js'
resource url:'http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css', disposition: 'head'
resource url:'http://localhost/css/flat-ui.css', disposition: 'head'
resource url:'http://localhost/css/base.css', disposition: 'head'
}
Is there a place I can set http:// localhost one time instead of listing it over and over for each resource? My dev environment uses localhost, but production will use a cdn.
Something like:
myCDN=http://amazons3.com
resource url:???/js/myfile01.js
resource url:???/js/myfile02.js
Sure you can, The config files are .groovy and should be processed just like any other code in the application.
To do so, just put in your config closure:
def myCDN='http://amazons3.com'
resource url: myCDN + '/js/myfile01.js'
resource url: myCDN + '/js/myfile02.js'
Good luck with it.
I have a JavaScript file making an ajax request to a file containing json data. The json data file is located in the public folder of Rails, however, the ajax request is returning a 404 not found error.
GET http://localhost:3000/public/data/album1.json 404 (Not Found)
Can anyone make a suggestion about what url to set for the ajax request, or where to put the json file if not in the public folder? Note, in addition to the url shown in the code below, I also tried url: 'data/album1.json' but it gave me the same result.
if (this._index === null){
$.ajax({
url: 'public/data/album1.json',
dataType: 'json',
data: {},
Try not including the public in the url, but including the slash:
/data/album1.json
Grails 2.1
I've declared the following new resource module to support Google Map API in my views:
'google-map' {
resource url: 'http://maps.googleapis.com/maps/api/js?key=MyGoogleApiKeyGoesHere&sensor=false', attrs: [type: "js"], disposition: 'head'
}
Now when I include this module into some of my pages I get the following HTML code in result:
<script src="http://maps.googleapis.com/maps/api/js" type="text/javascript" ></script>
As you can see the parameters part of URL was removed by some reason which causes an error (Google says that sensor parameter is required when I try to open the page).
Does anybody know how to prevent Grails Resources plug-in from removing query parameters from URLs?
I am using an ajax request which works in local, not in remote, because of an url problem. It looks like :
$.ajax({
type: "POST",
url: "../classes/file_to_process.php",
data: "my data"
success: function(msg){...}
})
I keep on having an error message : "The requested URL /classes/file_to_process.php {without the double dots behind it} was not found on this server"
My working directory is in a folder /prod, in which there is the index.php. The /classes folder is at the same level as /prod. So to fetch it from an jquery request, I use ../classes/file_to_process
I tried an absolute path by using pwd to fetch the correct path on the remote server, but I have the same message
Anybody has an idea ?
'classes' folder is on the same level as 'public', then you can't access it directly from the client (AJAX, JavaScript, etc). You need to either put it in the 'public' or map it to /classes virtual path. Or you can have a trusted .php file in your 'public' folder that accesses the 'classes' on the server side.
TL;DR;
From the client side you cannot access a file that is not being served to the client.