Select to view content in your preferred language

ArcGIS JS Proxy

343
4
01-04-2024 07:49 PM
Wade
by
New Contributor III

How to ensure that urlUtils is executed before loading the layer?

 

  urlUtils.addProxyRule({
            urlPrefix: "XXXXXXX/server/rest/services",
            proxyUrl: "https://XXXXXX/proxy.ashx"
        });

        const MAP = new MapImageLayer({
            url: "https://XXXXXX/MapServer",
            title: "XXXXXX",
            spatialReference: {
                wkid: 3826
            },
            visible: false,
            listMode: "hide-children"
        });

 

 

0 Kudos
4 Replies
Noah-Sager
Esri Regular Contributor

You could try using a RequestInterceptor to ensure that the layer uses the proxy URL:

https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#RequestInterceptor

 

0 Kudos
Wade
by
New Contributor III

Hi @Noah-Sager 

When I use proxy, my printing function seems to be unable to print private layers.

Is there a solution to this problem?

 

error:
code: 400
details: ['Error executing tool. Export Web Map Task : error …eb Map).\nFailed to execute (Export Web Map Task).']
extendedCode: -2147467261
message: "Unable to complete operation."

 

 

0 Kudos
Noah-Sager
Esri Regular Contributor

@Wade - couple things to consider here.

1. are you sure all the relevant requests are going through the proxy?

2. do you have to use a proxy? we do have other workflows for security: https://developers.arcgis.com/javascript/latest/secure-resources/

3. in the webmap_as_json sent to the print service, do you see any token or anything being passed in the request?

0 Kudos
Wade
by
New Contributor III

@Noah-Sager 

Yes, because a proxy is currently required to connect to ArcGIS Server, but printing problems may occur when using the proxy program.When using proxy, my layers are all private. In theory, I should directly bring in the proxy.config rules and log in to use the layer.

The current test results show that as long as proxy is used, it seems that the private layer cannot be used normally in printing.

 

Currently no similar examples can be found in arcgis document,Is there a solution to this?

0 Kudos