Queries are adding characters to REST service URLs

07-23-2020 11:40 AM
New Contributor II

I have a JS application hosted at myapp.domain.com. A little while ago, I decided to host web adaptor on the same domain as my JS application. So, the root of the web adaptor is myapp.domain.com/arcgis. This was helpful so that I can run staging and production GIS servers and set the base URL to various REST services as just "/arcgis/". It seemed like a reasonable place to use a relative path like that.

However, I just noticed a really weird behavior. When I turn on a layer with the layer-list widget, instead of sending a query to myapp.domain.com/arcgis/rest/myservice/mapserver/0, it sends the request to myapp.domain.com/arcgis/rest/myservice/mapserver/0/0 (note the extra trailing "/0"). In this example, I'm turning on the 0 sublayer of the particular map service. There are a lot of places in the code where I create querytasks and those aren't affected by this problem. If I switch out the base url of "/arcgis/" for "myapp.domain.com/arcgis/" the problem goes away.

So, for some reason it's doing this if the URLs use relative paths, but not if they use a complete path. Anyone have an idea why this is happening?

EDIT: JS API version 4.14

0 Kudos
0 Replies