config
require(["esri/config"], function(esriConfig) { /* code goes here */ });
esri/config
Configure global properties of the library.
The value of this module is an object with the following properties.
require(["esri/config"], function(esriConfig) {
esriConfig.request.proxyUrl = "/resource-proxy/Java/proxy.jsp";
});
Property Overview
Name | Type | Summary | Object | |
---|---|---|---|---|
String | The URL for font resources used by the Font class in FeatureLayer and CSVLayer labels. more details | more details | config | |
String | The default GeometryService used by widgets and other operations, such as on-the-fly projections. more details | more details | config | |
String | The URL for the utility service used by GeoRSSLayer to convert GeoRSS documents. more details | more details | config | |
String | The URL for the utility service used by KMLLayer to convert KML documents. more details | more details | config | |
String | The URL of the portal instance. more details | more details | config | |
Object | An object with properties that control various aspects of communication between the library and web servers. more details | more details | config | |
Object | The AMD loader's configuration object, which is loaded with each worker. more details | more details | config |
Property Details
- fontsUrlStringSince: ArcGIS API for JavaScript 4.8
The URL for font resources used by the Font class in FeatureLayer and CSVLayer labels. To use your own hosted fonts, you must follow the kebab-case naming convention (e.g. "arial-unicode-ms-bold").
- Default Value:"https://static.arcgis.com/fonts"
- See also:
Example:esriConfig.fontsUrl = "https://myserver.com/fonts";
- geometryServiceUrlString
The default GeometryService used by widgets and other operations, such as on-the-fly projections.
- Default Value:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer"
Example:esriConfig.geometryServiceUrl = "https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer";
- geoRSSServiceUrlString
The URL for the utility service used by GeoRSSLayer to convert GeoRSS documents.
- Default Value:"https://utility.arcgis.com/sharing/rss"
Example:esriConfig.geoRSSServiceUrl = "http://servername.domain.suffix/arcgis/sharing/rss";
- kmlServiceUrlStringSince: ArcGIS API for JavaScript 4.5
The URL for the utility service used by KMLLayer to convert KML documents.
- Default Value:"https://utility.arcgis.com/sharing/kml"
Example:esriConfig.kmlServiceUrl = "http://servername.domain.suffix/arcgis/sharing/kml";
- portalUrlString
The URL of the portal instance. If using an on-premise portal, this value should be set to the portal instance, for example:
https://www.example.com/arcgis
- Default Value:"https://www.arcgis.com"
- See also:
Example:// Set the hostname to the on-premise portal esriConfig.portalUrl = "https://myHostName.esri.com/arcgis"
- requestObject
An object with properties that control various aspects of communication between the library and web servers.
- Properties:
- optionalhttpsDomains String[]
List of domain suffixes known to support https. This will automatically upgrade requests made to such domains to use https instead of http when the application is not running on http. Note that port numbers should not be included in the domain suffix to be matched.
If no
httpsDomains
list exists , the API redirects all calls using https. If the list exists and a domain of a required http resource is not listed, the API sends the URL as it is specified within the code. Likewise, if the list exists and the domain of a required http resource is listed in it, the API sends an https request to that resource.The list includes the following domain suffixes by default:
arcgis.com
arcgisonline.com
optionalinterceptors RequestInterceptor[]Allows developers to modify requests before or after they are sent. The first interceptor that matches the request URL will be used.
Example:
const featureLayerUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"; esriConfig.request.interceptors.push({ // set the `urls` property to the URL of the FeatureLayer so that this // interceptor only applies to requests made to the FeatureLayer URL urls: featureLayerUrl, // use the BeforeInterceptorCallback to check if the query of the // FeatureLayer has a maxAllowableOffset property set. // if so, then set the maxAllowableOffset to 0 before: function(params) { if (params.requestOptions.query.maxAllowableOffset) { params.requestOptions.query.maxAllowableOffset = 0; } }, // use the AfterInterceptorCallback to check if `ssl` is set to 'true' // on the response to the request, if it's set to 'false', change // the value to 'true' before returning the response after: function(response) { if (!response.ssl) { response.ssl = true; } } });
optionalmaxUrlLength NumberDefault Value:2000Maximum number of characters allowed in the URL for HTTP GET requests made by request. If this limit is exceeded, HTTP POST method will be used.
optionalproxyRules Object[]A proxy rule defines a proxy for a set of resources with an identical URL prefix. When using esriRequest, if a target URL matches a rule, then the request will be sent to the specified proxy. Rather than populating this array directly, use the urlUtils.addProxyRule() method. Rule objects have the following properties:
optionalproxyUrl StringDefault Value:nullResource proxy for your application. It is used by the library when communicating with a web server hosted on a domain that is different from the domain where your application is hosted.
The library may or may not use the proxy depending on the type of request made, whether the server support CORS, whether the application is being run on older versions of browsers etc. To keep it simple, it is recommended that you always configure a resource proxy for your application.
You can download the resource proxy from this GitHub repo.
require(["esri/config"], function(esriConfig) { esriConfig.request.proxyUrl = "/resource-proxy/Java/proxy.jsp"; });
optionaltimeout NumberDefault Value:60000Number of milliseconds request will wait for response from a server. If a server fails to respond before this time expires, then the request is considered to have encountered an error.
optionaltrustedServers String[]Since: 4.9
Indicates whether cross origin requests made to the associated server should include credentials such as cookies and authorization headers.require(["esri/config"], function(esriConfig) { esriConfig.request.trustedServers.push("[<protocol>//]<hostname>.<domain>[:<port>]"); });
optionaluseIdentity BooleanDefault Value:trueSince: 4.5
Indicates whetheresri/request
will request a credential fromIdentityManager
. - See also:
- workersObject
The AMD loader's configuration object, which is loaded with each worker. Modify the configuration to specify locations of packages to be loaded with the workers framework or to define a feature detection.
- Properties:
- optionalloaderUrl Object
The absolute url to the AMD loader used in the worker. The default url points to the AMD loader used by the API.
optionalloaderConfig ObjectThe configuration parameters for the workers framework.
- Specification:
- optionalbaseUrl String
The AMD loader loads all code relative to the baseUrl.
optionalhas ObjectDetermines if the specified feature capabilities are supported.
optionalpaths ObjectMap of module id fragments to file paths.
optionalmap ObjectMap paths in module identifiers to different paths.
optionalpackages Object[]An array of objects which provide the package name and its location.
Example:esriConfig.workers.loaderConfig = { paths: { workerScripts: window.location.href.replace(/\/[^/]+$/, "/workerScripts"), dojo: "https://ajax.googleapis.com/ajax/libs/dojo/1.11.2/dojo/" } }; // load workerScripts/Calculator.js in the workers framework // and invoke its "getMaxNumber" method workers.open(this, "workerScripts/Calculator") .then(function(connection) { return connection.invoke("getMaxNumber", [0, 1, 2, 3, 4]); }) .then(function(result) { console.log(result); }); //********************************************************* // module: workerScripts/Calculator.js //********************************************************* define([], function (promiseUtils) { return { // this function can be invoked from the main thread getMaxNumber: function (number) { return Math.max.apply(null, numbers); } }; });
Type Definitions
- AfterInterceptorCallback(response)
Makes changes to the response after the request is sent, but before it's returned to the caller.
Parameter:response RequestResponseThe response object.
- BeforeInterceptorCallback(params){Object}
Makes changes to the request URL or options before the request is sent.
If
null
orundefined
is returned, the request is sent with whatever changes were made to the parameters. If an Error is returned, the request is rejected with an esriError. If any other type is returned, the request is resolved with the returned value as the response data (request will not be sent).Parameters:params ObjectParameters object that specifies the two properties that can be set.
Specification:url StringThe request URL.
requestOptions RequestOptionsThe options specified by the user in the data request. See RequestOptions for available properties.
Returns:Type Description Object Returns null
,undefined
, Error, or response data.
- RequestInterceptor
Specifies the object used for intercepting and modifying requests made via esriRequest.
- Properties:
- optionalafter AfterInterceptorCallback
Makes changes to the response after the request is sent, but before it's returned to the caller.
optionalbefore BeforeInterceptorCallbackMake changes to the request URL or options before the request is sent.
optionalheaders ObjectSets or adds headers into
requestOptions.headers
. See also: requestOptions.optionalquery ObjectSets or adds query parameters into
requestOptions.query
. See also: requestOptions.optionalresponseData ObjectHardcodes the response. The request will not be sent. This is resolved as the response
data
.optional Specifies the URL(s) to apply to the interceptors. If the value is type
String
, then it matches if the request URL starts with that string. If null or undefined, the interceptor will apply to all relevant requests.