require(["esri/config"], function(esriConfig) { /* code goes here */ });
Object: esri/config
Since: ArcGIS API for JavaScript 4.0

Configure global properties of the library.

The value of this module is an object with the following properties.

Example:
require(["esri/config"], function(esriConfig) {
  esriConfig.request.proxyUrl = "/resource-proxy/Java/proxy.jsp";
});

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryObject
String

The URL for font resources used by the Font class in FeatureLayer and CSVLayer labels.

more details
more detailsconfig
String

The default GeometryService used by widgets and other operations, such as on-the-fly projections.

more details
more detailsconfig
String

The URL for the utility service used by GeoRSSLayer to convert GeoRSS documents.

more details
more detailsconfig
String

The URL for the utility service used by KMLLayer to convert KML documents.

more details
more detailsconfig
String

The URL of the portal instance.

more details
more detailsconfig
Object

An object with properties that control various aspects of communication between the library and web servers.

more details
more detailsconfig
Object

The AMD loader's configuration object, which is loaded with each worker.

more details
more detailsconfig

Property Details

fontsUrlString
Since: 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";
kmlServiceUrlString
Since: 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:
httpsDomains String[]
optional

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
optional

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;
    }
  }
});
maxUrlLength Number
optional
Default Value:2000

Maximum 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.

proxyRules Object[]
optional

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:

Specification:
proxyUrl String
optional

The URL of the proxy.

urlPrefix String
optional

URL prefix for resources that need to be accessed through a specific proxy.

proxyUrl String
optional
Default Value:null

Resource 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";
});
timeout Number
optional
Default Value:60000

Number 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.

trustedServers String[]
optional

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>]");
});
useIdentity Boolean
optional
Default Value:true

Since: 4.5
Indicates whether esri/request will request a credential from IdentityManager.

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:
loaderUrl Object
optional

The absolute url to the AMD loader used in the worker. The default url points to the AMD loader used by the API.

loaderConfig Object
optional

The configuration parameters for the workers framework.

Specification:
baseUrl String
optional

The AMD loader loads all code relative to the baseUrl.

has Object
optional

Determines if the specified feature capabilities are supported.

paths Object
optional

Map of module id fragments to file paths.

map Object
optional

Map paths in module identifiers to different paths.

packages Object[]
optional

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:

The response object.

BeforeInterceptorCallback(params){Object}

Makes changes to the request URL or options before the request is sent.

If null or undefined 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 Object

Parameters object that specifies the two properties that can be set.

Specification:
url String

The request URL.

requestOptions RequestOptions

The options specified by the user in the data request. See RequestOptions for available properties.

Returns:
TypeDescription
ObjectReturns null, undefined, Error, or response data.
RequestInterceptor

Specifies the object used for intercepting and modifying requests made via esriRequest.

Properties:
optional

Makes changes to the response after the request is sent, but before it's returned to the caller.

optional

Make changes to the request URL or options before the request is sent.

headers Object
optional

Sets or adds headers into requestOptions.headers. See also: requestOptions.

query Object
optional

Sets or adds query parameters into requestOptions.query. See also: requestOptions.

responseData Object
optional

Hardcodes 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.

API Reference search results

NameTypeModule
Loading...