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 | |
---|---|---|---|---|
fontsUrl | String | The URL for font resources used by the Font class with 2D WebGL enabled FeatureLayer and CSVLayer. more details | more details | config |
geometryServiceUrl | String | The default GeometryService used by widgets and other operations, such as on-the-fly projections. more details | more details | config |
geoRSSServiceUrl | String | The URL for the utility service used by GeoRSSLayer to convert GeoRSS documents. more details | more details | config |
kmlServiceUrl | String | The URL for the utility service used by KMLLayer to convert KML documents. more details | more details | config |
portalUrl | String | The URL of the portal instance. more details | more details | config |
request | Object | An object with properties that control various aspects of communication between the library and web servers. more details | more details | config |
workers | 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 with 2D WebGL enabled FeatureLayer and CSVLayer. To use your own hosted fonts, make sure to follow our naming conventions (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:
- optionalcorsDetection Boolean
Indicates whether the library automatically detects if CORS (Cross-Origin Resource Sharing) specification is supported by ArcGIS Servers used in your application.
Upon successful detection, the server will be added to
corsEnabledServers
list. CORS detection will not be performed for a server if it is already listed incorsEnabledServers
.The default is
true
if your application is running in a web browser, orfalse
if your application is running on Apache Cordova platform.optionalcorsDetectionTimeout NumberDefault Value:15Number of seconds to wait for response from the ArcGIS Server during CORS detection. If the detection is not complete before this time expires, then it is assumed that the server does not support CORS.
Applicable when
corsDetection
is true.optional A list of servers known to support CORS specification.
By default, this list includes many Esri hosted servers that are known to support CORS and is updated at every release as the list grows. The API is capable of automatically detecting CORS support for servers used in an application (see
corsDetection
). If you are aware that a server supports CORS, add it to this list. Since the API includes some servers by default it's important to add items onto this array rather than overwriting it.Example:
// Add a known server to the list. require(["esri/config"], function(esriConfig) { esriConfig.request.corsEnabledServers.push("<hostname>.<domain>:<port>"); });
You can also pass objects to this property with the following specification:
- Specification:
optional The host name of the server to add to the list of CORS-enabled servers.
optionalwithCredentials BooleanDefault Value:falseIndicates whether requests made to the associated server should include credentials such as cookies and authorization headers.
optionalforceProxy BooleanDefault Value:falseIndicates whether the proxy specified in
proxyUrl
is used for all AJAX requests made using request and images added using<img>
element.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. An array of interceptors that will return the first one that matches. If no urls are specified, will apply to all relevant requests.
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.
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.
optional Default Value:with-credentialsIndicates whether the library will use CORS-enabled requests when communicating with a web server hosted on a domain that is different from the domain where the application is hosted. If
true
, AJAX requests are directly made to servers that support CORS. Ifwith-credentials
is specified, then AJAX requests will use credentials stored in a client's cookies. Iffalse
, direct requests are not made. A proxy will be used if available.optionaluseIdentity BooleanDefault Value:trueSince: 4.5
Indicates whetheresri/request
will request a credential fromIdentityManager
.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:
- 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
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, requestOptions){Object}
Can make changes to the url or options before the request is sent. The request is rejected with an esriError if Error is returned, or it is resolved with the returned value as the response
data
.Parameters:params ObjectoptionalParameters object that specifies the two properties that can be set.
Specification:url ObjectoptionalSpecify the url(s) to apply to the interceptor.
requestOptions RequestOptionsoptionalAn object with the following properties that describe the request.
Returns:Type Description Object Return the response data, or an Error.
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 BeforeInterceptorCallbackCallback function that can make changes to the url or options before the request is sent.
optionalheaders String[]Sets or adds headers into
requestOptions.headers
.optionalquery ObjectAppends a query statement to the request in the Query String Parameters of the header.
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 undefined, interceptors will apply to all relevant requests.
API Reference search results
Name | Type | Module |
---|