Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
feat: support for custom Nominatim API base URL and fixes unable to get mapbox access token (#125)
秋酿c663373ccc0a
diff --git a/.env.example b/.env.exampleindex 66a81465..32b89009 100644--- a/.env.example+++ b/.env.example@@ -24,6 +24,9 @@ NUXT_PUBLIC_MAPBOX_ACCESS_TOKEN=# Mapbox secret access token for server-side, Mapbox Search API (Reverse Geocoding)NUXT_MAPBOX_ACCESS_TOKEN=+# Custom Nominatim API base URL (use MapBox or proxy when official API is blocked in mainland China)+NUXT_NOMINATIM_BASE_URL=+# Storage provider (s3/local/openlist)NUXT_STORAGE_PROVIDER=s3# S3 storage provider configurationdiff --git a/nuxt.config.ts b/nuxt.config.tsindex 7e1557de..e23bd0eb 100644--- a/nuxt.config.ts+++ b/nuxt.config.ts@@ -69,6 +69,9 @@ export default defineNuxtConfig({mapbox: {accessToken: '',},+ nominatim: {+ baseUrl: 'https://nominatim.openstreetmap.org',+ },STORAGE_PROVIDER: 's3' satisfies 's3' | 'local' | 'openlist',provider: {s3: {diff --git a/server/services/location/geocoding.ts b/server/services/location/geocoding.tsindex 3737959b..4de5c1bf 100644--- a/server/services/location/geocoding.ts+++ b/server/services/location/geocoding.ts@@ -110,11 +110,15 @@ export class MapboxGeocodingProvider implements GeocodingProvider {* 免费的地理编码服务,适合开发和小规模使用*/export class NominatimGeocodingProvider implements GeocodingProvider {- private readonly baseUrl = 'https://nominatim.openstreetmap.org'+ private readonly baseUrl: stringprivate readonly userAgent = 'chronoframe/1.0'private lastRequestTime = 0private readonly rateLimitMs = 1000 // Nominatim 要求至少1秒间隔+ constructor(baseUrl?: string) {+ this.baseUrl = baseUrl || useRuntimeConfig().nominatim?.baseUrl || 'https://nominatim.openstreetmap.org'+ }+async reverseGeocode(lat: number, lon: number): Promise<LocationInfo | null> {try {return await withRetry(async () => {@@ -199,8 +203,7 @@ export class NominatimGeocodingProvider implements GeocodingProvider {* @description 优先使用 Mapbox,如果没有配置则回退到 Nominatim*/function createGeocodingProvider(): GeocodingProvider {- const mapboxToken =- useRuntimeConfig().MAPBOX_ACCESS_TOKEN || process.env.MAPBOX_ACCESS_TOKEN+ const mapboxToken = useRuntimeConfig().mapbox?.accessTokenif (mapboxToken) {return new MapboxGeocodingProvider(mapboxToken)