WebMapServiceImageryProvider proxy


I would like to set a proxy for WebMapServiceImageryProvider, however it looks like CesiumJS is ignoring the proxy I set as below:

var deformationNaples = new Cesium.WebMapServiceImageryProvider({
url: “http://ugbd.get-it.it/geoserver/wms”,
layers: “geonode:NAPOLI_DEFORMAZIONE_MAP”,
parameters: {version: “1.1.0”, transparent: “TRUE”, format: “image/png”, srs: “EPSG:4326”},
rectangle: Cesium.Rectangle.fromDegrees(14.05072, 40.82471, 14.30817, 40.91915),
proxy: new Cesium.DefaultProxy(“https://ugbd.get-it.it/proxy/image/?proxyTo=”)


This URL works.

However I still get errors like:

Access to image at ‘http://ugbd.get-it.it/geoserver/wms?version=1.1.0&transparent=TRUE&format=image%2Fpng&srs=EPSG%3A4326&service=WMS&request=GetMap&styles=&layers=geonode%3ANAPOLI_DEFORMAZIONE_MAP&bbox=13.974609374999995%2C40.78125%2C14.062500000000004%2C40.869140625&width=256&height=256’ from origin ‘http://localhost’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

How can I solve this problem?


The fact that it’s not appending the proxy seems like a bug. I haven’t had a chance to confirm it yet, and I don’t see any issue open for it (https://github.com/AnalyticalGraphicsInc/cesium) so that might be worth opening a bug report for.

In the mean time though, I noticed this WMS example just sticks the proxy part at the beginning of the URL:

Does that work if you do that?

The other thing to confirm this is a bug would be to open the network tab in your browser and see if you can confirm that it is indeed making a request without taking into account the specified proxy.

I did a little more digging, and it looks like the doc example is wrong, in that proxy is not an option on the WMS provider class. There’s still an issue because of a URL encoding, so I opened a bug report for it:


Thanks Omar, and sorry for my late reply.

As expected in the network tab the proxy is not appended.

I tried attaching the proxy at the beginning of the URL:

var deformationNaples = new Cesium.WebMapServiceImageryProvider({
url: “https://ugbd.get-it.it/proxy/image/?proxyTo=http://ugbd.get-it.it/geoserver/wms”,
layers: “geonode:NAPOLI_DEFORMAZIONE_MAP”,
parameters: {version: “1.1.0”, transparent: “TRUE”, format: “image/png”, srs: “EPSG:4326”},
rectangle: Cesium.Rectangle.fromDegrees(14.05072, 40.82471, 14.30817, 40.91915)


This is the resulting request: https://ugbd.get-it.it/proxy/image/?version=1.1.0&transparent=TRUE&format=image%2Fpng&srs=EPSG%3A4326&proxyTo=http%3A%2F%2Fugbd.get-it.it%2Fgeoserver%2Fwms&service=WMS&request=GetMap&styles=&layers=geonode%3ANAPOLI_DEFORMAZIONE_MAP&bbox=14.238281249999996%2C40.869140625%2C14.326171875000005%2C40.95703125&width=256&height=256, which is wrong. Is it because of the placement of the question mark? I have the chance to ask the proxy providers to build the proxy in a specific way.

In my own proxy, I’ve found it much more convenient to put the target URL in the path rather than the query portion of the URL. That way you can give a pre-proxied URL to just about anything (Cesium or otherwise), and it can be treated like a normal URL, even through query parameter manipulations. Here’s an example of a URL for our proxy:

The only problem we’ve had with this is that some reverse proxies (I’m looking at you Apache) will replace the “https://” with “https:/” in the target URL (remove a slash) because the double slash is not technically allowed in a path. So our proxy just detects that and re-adds the removed slash.

Thanks Kevin, your suggestion works. So:

var deformationNaples = new Cesium.WebMapServiceImageryProvider({
url: “https://ugbd.get-it.it/proxy/image/?proxyTo=http://ugbd.get-it.it/geoserver/wms?srs=EPSG:4326&transparent=TRUE&format=image/png”,


There is one thing I am curious about though. In this case the URL becomes https://ugbd.get-it.it/proxy/image/?proxyTo=http%3A%2F%2Fugbd.get-it.it%2Fgeoserver%2Fwms%3Fsrs&transparent=TRUE&format=image%2Fpng&service=WMS&version=1.1.1&request=GetMap&styles=&layers=geonode%3ANAPOLI_DEFORMAZIONE_MAP&bbox=14.238281249999996%2C40.78125%2C14.41406249999999%2C40.95703125&width=256&height=256&srs=EPSG%3A4326. As you can see the first parameter’s value (EPSG:4326) is not assigned in the URL, and that happened to all the parameters that I placed first. I put there something extra temporarily (srs) so that the request is not affected. Can you guess why this is happening?

You haven’t followed my suggestion; you’re still putting the target URL in a query parameter instead of in the path part of the URL. Given that you’re using a query parameter (proxyTo=), you can’t pre-proxy-ify the URL like that. It’s going to get mangled. WebMapServiceImageryProvider needs to be able to adjust query parameters, and it can’t do that when you’ve hidden the URL that needs to be adjusted inside a query parameter like that.

Thanks Kevin, I believe it is clear now. I asked the proxy providers to remove the query parameter (proxyTo=) from it, then I will attach the proxy in front of the target URL.