File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import type { APILocations } from "@/maps/schema" ;
22
33export const OVERPASS_API = "https://overpass-api.de/api/interpreter" ;
4+ export const OVERPASS_API_FALLBACK = "https://overpass.private.coffee/api/interpreter" ;
45export const GEOCODER_API = "https://photon.komoot.io/api/" ;
56export const PASTEBIN_API_POST_URL =
67 "https://cors-anywhere.com/https://pastebin.com/api/api_post.php" ;
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import {
1212import { safeUnion } from "@/maps/geo-utils" ;
1313
1414import { cacheFetch } from "./cache" ;
15- import { LOCATION_FIRST_TAG , OVERPASS_API } from "./constants" ;
15+ import { LOCATION_FIRST_TAG , OVERPASS_API , OVERPASS_API_FALLBACK } from "./constants" ;
1616import type {
1717 EncompassingTentacleQuestionSchema ,
1818 HomeGameMatchingQuestions ,
@@ -26,12 +26,21 @@ export const getOverpassData = async (
2626 loadingText ?: string ,
2727 cacheType : CacheType = CacheType . CACHE ,
2828) => {
29- const response = await cacheFetch (
30- `${ OVERPASS_API } ?data=${ encodeURIComponent ( query ) } ` ,
29+ const encodedQuery = encodeURIComponent ( query ) ;
30+ let response = await cacheFetch (
31+ `${ OVERPASS_API } ?data=${ encodedQuery } ` ,
3132 loadingText ,
3233 cacheType ,
3334 ) ;
3435
36+ if ( ! response . ok ) {
37+ response = await cacheFetch (
38+ `${ OVERPASS_API_FALLBACK } ?data=${ encodedQuery } ` ,
39+ loadingText ,
40+ cacheType ,
41+ ) ;
42+ }
43+
3544 if ( ! response . ok ) {
3645 toast . error (
3746 `Could not load data from Overpass: ${ response . status } ${ response . statusText } ` ,
You can’t perform that action at this time.
0 commit comments