File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { twMerge } from "tailwind-merge";
44import {
55 PASTEBIN_API_POST_URL ,
66 PASTEBIN_API_RAW_URL ,
7+ PASTEBIN_API_RAW_URL_PROXIED ,
78} from "@/maps/api/constants" ;
89
910export function cn ( ...inputs : ClassValue [ ] ) {
@@ -84,7 +85,14 @@ export async function uploadToPastebin(
8485}
8586
8687export async function fetchFromPastebin ( pasteId : string ) : Promise < string > {
87- const response = await fetch ( PASTEBIN_API_RAW_URL + pasteId ) ;
88+ let response ;
89+ try {
90+ // prefer querying Pastebin directly since CORS proxy is unreliable
91+ response = await fetch ( PASTEBIN_API_RAW_URL + pasteId ) ;
92+ } catch {
93+ // CORS error; happens if the paste is not owned by a Pastebin Pro user
94+ response = await fetch ( PASTEBIN_API_RAW_URL_PROXIED + pasteId ) ;
95+ }
8896
8997 if ( ! response . ok ) {
9098 throw new Error (
Original file line number Diff line number Diff line change @@ -6,7 +6,8 @@ export const OVERPASS_API_FALLBACK =
66export const GEOCODER_API = "https://photon.komoot.io/api/" ;
77export const PASTEBIN_API_POST_URL =
88 "https://cors-anywhere.com/https://pastebin.com/api/api_post.php" ;
9- export const PASTEBIN_API_RAW_URL =
9+ export const PASTEBIN_API_RAW_URL = "https://pastebin.com/raw/" ;
10+ export const PASTEBIN_API_RAW_URL_PROXIED =
1011 "https://cors-anywhere.com/https://pastebin.com/raw/" ;
1112
1213export const ICON_COLORS = {
You can’t perform that action at this time.
0 commit comments