Skip to content

Commit d1f5b5b

Browse files
committedAug 5, 2022
url fix
1 parent 3f1f825 commit d1f5b5b

File tree

8 files changed

+65
-21
lines changed

8 files changed

+65
-21
lines changed
 

‎Samples/Animations/Animate a GPS trace/Animate a GPS trace.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
},
3737
{
3838
displayName: 'Kuhkopfsteig trail (GPX)',
39-
url: '/data/Gpx/kuhkopfsteig-fv.gpx',
39+
url: '/data/gpx/kuhkopfsteig-fv.gpx',
4040

4141
//Perform a linear interpolation on the `ele` property.
4242
valueInterpolations: [{ propertyPath: 'ele' }]
4343
},
4444
{
4545
displayName: 'Bike race GPS trace (GPX)',
46-
url: '/data/Gpx/race-gps-trace.gpx',
46+
url: '/data/gpx/race-gps-trace.gpx',
4747

4848
//Perform a linear interpolation on the `ele` property.
4949
valueInterpolations: [{ propertyPath: 'ele' }]

‎Samples/Spatial IO Module/Load spatial data (simple)/Load spatial data (simple).html

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
map.layers.add(layer);
5757

5858
//Read an XML file from a URL or pass in a raw XML string.
59-
atlas.io.read(window.location.origin + '/data/Gpx/Route66Attractions.xml').then(r => {
59+
atlas.io.read(window.location.origin + '/data/gpx/Route66Attractions.xml').then(r => {
6060
if (r) {
6161
//Add the feature data to the data source.
6262
datasource.add(r);

‎Samples/Spatial IO Module/Spatial data gallery/Spatial data gallery.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<script>
2323
var map, datasource, layer, imageLayers = [], imageIcons = [], loadingIcon, statsOuput;
2424

25-
var proxyServiceUrl = window.location.origin + '/CorsEnabledProxyService.ashx?url=';
25+
var proxyServiceUrl = 'https://samples.azuremaps.com/api/GetDataFromUrl?url=';
2626

2727
function GetMap() {
2828
loadingIcon = document.getElementById('loadingIcon');
@@ -64,7 +64,7 @@
6464

6565
function loadData(url, isAbsolute) {
6666
if (!isAbsolute) {
67-
url = window.location.origin + url;
67+
url = 'https://samples.azuremaps.com' + url;
6868
}
6969

7070
loadingIcon.style.display = '';
@@ -266,12 +266,12 @@
266266
<div id="External" class="tabcontent" style="display:block;">
267267
These files are hosted on other domains.
268268
<br /><br />
269-
<b>Proxied feeds</b>
269+
<!--<b>Proxied feeds</b>
270270
<br /><br />
271271
These feeds are hosted on endpoints that don't have CORs enabled. A proxy service is used to make the cross domain request possible.
272272
<ul>
273273
<li><a href="javascript:void(0);" onclick="loadData('https://www.brianabbott.net/media/kml/NYC-Transit.kmz', true);">New York City Metro (KMZ)</a></li>
274-
</ul>
274+
</ul>-->
275275

276276
<b>CORs enabled feeds</b>
277277
<ul>

‎Services/SampleFunctions/GetAzureMapsKey.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace SampleFunctions
88
{
99
public static class GetAzureMapsKey
1010
{
11-
private static readonly string[] allowd = { "https://samples.azuremaps.com/",
12-
"https://demo.azuremaps.com/",
13-
"http://localhost"};
11+
private static readonly string[] allowed = { "https://samples.azuremaps.com/",
12+
"https://demo.azuremaps.com/",
13+
"http://localhost"};
1414

1515
[FunctionName("GetAzureMapsKey")]
1616
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req)
@@ -19,7 +19,7 @@ public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get"
1919
if (string.IsNullOrEmpty(referer))
2020
return new UnauthorizedResult();
2121

22-
string result = Array.Find(allowd, site => referer.StartsWith(site, StringComparison.OrdinalIgnoreCase));
22+
string result = Array.Find(allowed, site => referer.StartsWith(site, StringComparison.OrdinalIgnoreCase));
2323
if (string.IsNullOrEmpty(result))
2424
return new UnauthorizedResult();
2525

‎Services/SampleFunctions/GetAzureMapsToken.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ namespace SampleFunctions
1111
{
1212
public static class GetAzureMapsToken
1313
{
14-
private static readonly string[] allowd = { "https://samples.azuremaps.com/",
15-
"https://demo.azuremaps.com/",
16-
"http://localhost"};
14+
private static readonly string[] allowed = { "https://samples.azuremaps.com/",
15+
"https://demo.azuremaps.com/",
16+
"http://localhost"};
1717

1818
[FunctionName("GetAzureMapsToken")]
1919
public static async Task<IActionResult> RunAsync([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req)
@@ -22,7 +22,7 @@ public static async Task<IActionResult> RunAsync([HttpTrigger(AuthorizationLevel
2222
if (string.IsNullOrEmpty(referer))
2323
return new UnauthorizedResult();
2424

25-
string result = Array.Find(allowd, site => referer.StartsWith(site, StringComparison.OrdinalIgnoreCase));
25+
string result = Array.Find(allowed, site => referer.StartsWith(site, StringComparison.OrdinalIgnoreCase));
2626
if (string.IsNullOrEmpty(result))
2727
return new UnauthorizedResult();
2828

‎Services/SampleFunctions/GetBingMapsKey.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace SampleFunctions
1212
{
1313
public static class GetBingMapsKey
1414
{
15-
private static readonly string[] allowd = { "https://samples.bingmapsportal.com/",
16-
"http://localhost"};
15+
private static readonly string[] allowed = { "https://samples.bingmapsportal.com/",
16+
"http://localhost"};
1717

1818
[FunctionName("GetBingMapsKey")]
1919
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req)
@@ -22,7 +22,7 @@ public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get"
2222
if (string.IsNullOrEmpty(referer))
2323
return new UnauthorizedResult();
2424

25-
string result = Array.Find(allowd, site => referer.StartsWith(site, StringComparison.OrdinalIgnoreCase));
25+
string result = Array.Find(allowed, site => referer.StartsWith(site, StringComparison.OrdinalIgnoreCase));
2626
if (string.IsNullOrEmpty(result))
2727
return new UnauthorizedResult();
2828

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Net.Http;
3+
using System.Threading.Tasks;
4+
using Microsoft.AspNetCore.Mvc;
5+
using Microsoft.Azure.WebJobs;
6+
using Microsoft.Azure.WebJobs.Extensions.Http;
7+
using Microsoft.AspNetCore.Http;
8+
using System.Web;
9+
10+
namespace SampleFunctions
11+
{
12+
public static class GetDataFromUrl
13+
{
14+
private static readonly string[] allowed = { "https://samples.azuremaps.com/",
15+
"http://localhost"};
16+
17+
private static readonly HttpClient httpClient = new();
18+
19+
[FunctionName("GetDataFromUrl")]
20+
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req)
21+
{
22+
string referer = req.Headers["Referer"];
23+
if (string.IsNullOrEmpty(referer))
24+
return new UnauthorizedResult();
25+
26+
string result = Array.Find(allowed, site => referer.StartsWith(site, StringComparison.OrdinalIgnoreCase));
27+
if (string.IsNullOrEmpty(result))
28+
return new UnauthorizedResult();
29+
30+
string url = req.Query["url"];
31+
if (string.IsNullOrEmpty(url))
32+
return new BadRequestObjectResult("Please pass a valid URL on the query string.");
33+
34+
using var response = await httpClient.GetAsync(HttpUtility.UrlDecode(url));
35+
36+
if (!response.IsSuccessStatusCode)
37+
return new BadRequestObjectResult("An error occurred. It was not possible to get the data of this URL.");
38+
39+
var content = await response.Content.ReadAsStringAsync();
40+
41+
return new OkObjectResult(content);
42+
}
43+
}
44+
}

‎Services/SampleFunctions/GetGeolocation.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace SampleFunctions
1313
{
1414
public static class GetGeolocation
1515
{
16-
private static readonly string[] allowd = { "https://samples.azuremaps.com/",
17-
"http://localhost"};
16+
private static readonly string[] allowed = { "https://samples.azuremaps.com/",
17+
"http://localhost"};
1818

1919
private static readonly HttpClient httpClient = new();
2020

@@ -25,7 +25,7 @@ public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anon
2525
if (string.IsNullOrEmpty(referer))
2626
return new UnauthorizedResult();
2727

28-
string result = Array.Find(allowd, site => referer.StartsWith(site, StringComparison.OrdinalIgnoreCase));
28+
string result = Array.Find(allowed, site => referer.StartsWith(site, StringComparison.OrdinalIgnoreCase));
2929
if (string.IsNullOrEmpty(result))
3030
return new UnauthorizedResult();
3131

0 commit comments

Comments
 (0)