fix: use relative proxy paths under subpath
This commit is contained in:
1 parent
d91858addc
commit
c0c612c0cc
1 file changed
+12
-4
Vendored
+12
-4
@@ -13,6 +13,14 @@
|
|||||||
// Progress and build diagnostics are only interesting while the debug panel
|
// Progress and build diagnostics are only interesting while the debug panel
|
||||||
// is on; a wall display must not fill the console with them.
|
// is on; a wall display must not fill the console with them.
|
||||||
var DEBUG_LOG = !!(window.CONFIG && window.CONFIG.debug);
|
var DEBUG_LOG = !!(window.CONFIG && window.CONFIG.debug);
|
||||||
|
var BASE_PATH = (function () {
|
||||||
|
var p = window.location.pathname || '/';
|
||||||
|
if (p.charAt(p.length - 1) !== '/') {
|
||||||
|
var i = p.lastIndexOf('/');
|
||||||
|
p = i >= 0 ? p.substring(0, i + 1) : '/';
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
})();
|
||||||
function dbgLog() {
|
function dbgLog() {
|
||||||
if (DEBUG_LOG) console.log.apply(console, arguments);
|
if (DEBUG_LOG) console.log.apply(console, arguments);
|
||||||
}
|
}
|
||||||
@@ -1408,7 +1416,7 @@ var GROUND_STYLE = GROUND_STYLE_CFG === 'satellite' ? 'satellite' : 'streets';
|
|||||||
var GROUND_TILE_DIRECT = (GROUND_STYLE === 'satellite')
|
var GROUND_TILE_DIRECT = (GROUND_STYLE === 'satellite')
|
||||||
? 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/'
|
? 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/'
|
||||||
: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/';
|
: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/';
|
||||||
var GROUND_TILE_PROXY = (GROUND_STYLE === 'satellite') ? '/esri/imagery/' : '/esri/streets/';
|
var GROUND_TILE_PROXY = BASE_PATH + (GROUND_STYLE === 'satellite' ? 'esri/imagery/' : 'esri/streets/');
|
||||||
// direct by default: works from any origin, including a plain file:// open
|
// direct by default: works from any origin, including a plain file:// open
|
||||||
var GROUND_TILE_URL = GROUND_TILE_DIRECT;
|
var GROUND_TILE_URL = GROUND_TILE_DIRECT;
|
||||||
var GROUND_TILE_ID_PREFIX = GROUND_STYLE === 'satellite' ? 'sat/' : '';
|
var GROUND_TILE_ID_PREFIX = GROUND_STYLE === 'satellite' ? 'sat/' : '';
|
||||||
@@ -2127,7 +2135,7 @@ var ELEV_UNIT_PX = 256 / ELEV_TILES_PER; // canvas px per z11 tile
|
|||||||
// elevation-tiles-prod (AWS) answers cross-origin GETs with CORS, so the
|
// elevation-tiles-prod (AWS) answers cross-origin GETs with CORS, so the
|
||||||
// DEM also loads without our server; /terrarium/ is preferred when present.
|
// DEM also loads without our server; /terrarium/ is preferred when present.
|
||||||
var ELEV_TILE_DIRECT = 'https://s3.amazonaws.com/elevation-tiles-prod/terrarium/';
|
var ELEV_TILE_DIRECT = 'https://s3.amazonaws.com/elevation-tiles-prod/terrarium/';
|
||||||
var ELEV_TILE_PROXY = '/terrarium/';
|
var ELEV_TILE_PROXY = BASE_PATH + 'terrarium/';
|
||||||
var ELEV_TILE_URL = ELEV_TILE_DIRECT;
|
var ELEV_TILE_URL = ELEV_TILE_DIRECT;
|
||||||
// (the probe needs both URL pairs assigned, so it runs here, not at the
|
// (the probe needs both URL pairs assigned, so it runs here, not at the
|
||||||
// ground-source block)
|
// ground-source block)
|
||||||
@@ -3184,14 +3192,14 @@ var OP_PUBLIC = [
|
|||||||
'https://overpass-api.de/api/interpreter',
|
'https://overpass-api.de/api/interpreter',
|
||||||
'https://maps.mail.ru/osm/tools/overpass/api/interpreter'
|
'https://maps.mail.ru/osm/tools/overpass/api/interpreter'
|
||||||
];
|
];
|
||||||
var OP_PROXY = ['/overpass/api/interpreter', '/overpass/mail/interpreter'];
|
var OP_PROXY = [BASE_PATH + 'overpass/api/interpreter', BASE_PATH + 'overpass/mail/interpreter'];
|
||||||
var CAR_ENDPOINTS = OP_PUBLIC.slice();
|
var CAR_ENDPOINTS = OP_PUBLIC.slice();
|
||||||
var _opProxyChecked = false;
|
var _opProxyChecked = false;
|
||||||
function opProbeProxy() {
|
function opProbeProxy() {
|
||||||
if (_opProxyChecked) return;
|
if (_opProxyChecked) return;
|
||||||
_opProxyChecked = true;
|
_opProxyChecked = true;
|
||||||
if (location.protocol === 'file:') return;
|
if (location.protocol === 'file:') return;
|
||||||
fetch('/overpass/api/interpreter', {
|
fetch(OP_PROXY[0], {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
body: 'data=' + encodeURIComponent('[out:json][timeout:5];out;')
|
body: 'data=' + encodeURIComponent('[out:json][timeout:5];out;')
|
||||||
|
|||||||
Reference in new issue
Block a user