Make api and images URL configurable via environment variables

pull/12/head^2
Manuel Kasper 2022-08-03 10:37:10 +02:00
rodzic d21213376c
commit 2698ec4284
21 zmienionych plików z 41 dodań i 37 usunięć

4
.env 100644
Wyświetl plik

@ -0,0 +1,4 @@
VUE_APP_API_URL="https://api.sotl.as"
VUE_APP_WSS_URL="wss://api.sotl.as"
VUE_APP_PHOTOS_URL="https://images.sotl.as/photos"
VUE_APP_PHOTOS_ORIGINAL_URL="https://sotlas-photos.s3.eu-central-003.backblazeb2.com/original"

Wyświetl plik

@ -154,7 +154,7 @@ export default {
if (matches) {
this.summitCode = (matches[1] + '/' + matches[2] + '-' + matches[3]).toUpperCase()
this.summitLoading = true
axios.get('https://api.sotl.as/summits/' + this.summitCode)
axios.get(process.env.VUE_APP_API_URL + '/summits/' + this.summitCode)
.then(response => {
this.summitLoading = false
this.summitInvalid = false

Wyświetl plik

@ -141,7 +141,7 @@ export default {
if (matches) {
this.summitCode = (matches[1] + '/' + matches[2] + '-' + matches[3]).toUpperCase()
this.summitLoading = true
axios.get('https://api.sotl.as/summits/' + this.summitCode)
axios.get(process.env.VUE_APP_API_URL + '/summits/' + this.summitCode)
.then(response => {
this.summitLoading = false
this.summitInvalid = false

Wyświetl plik

@ -28,7 +28,7 @@ export default {
this.loading = true
navigator.geolocation.getCurrentPosition(
position => {
axios.get('https://api.sotl.as/summits/near', { params: { lat: position.coords.latitude, lon: position.coords.longitude, limit: 5, maxDistance: 100000 } })
axios.get(process.env.VUE_APP_API_URL + '/summits/near', { params: { lat: position.coords.latitude, lon: position.coords.longitude, limit: 5, maxDistance: 100000 } })
.then(response => {
if (response.data.length === 0) {
alert('No summits within 100 km.')

Wyświetl plik

@ -36,7 +36,7 @@ export default {
},
methods: {
loadSolarData () {
axios.get('https://api.sotl.as/solardata/latest')
axios.get(process.env.VUE_APP_API_URL + '/solardata/latest')
.then(response => {
this.latest = response.data
})

Wyświetl plik

@ -38,7 +38,7 @@ export default {
mounted () {
if (!localStorage.getItem('swisstopoInfoShown')) {
// Check if we are in Switzerland
axios.get('https://api.sotl.as/my_country')
axios.get(process.env.VUE_APP_API_URL + '/my_country')
.then(response => {
if (response.data.country === 'CH') {
this.active = true

Wyświetl plik

@ -5,7 +5,7 @@ export default {
mixins: [ssoauth],
methods: {
loadActivations (callsign) {
return axios.get('https://api.sotl.as/activations/' + callsign)
return axios.get(process.env.VUE_APP_API_URL + '/activations/' + callsign)
.then(response => {
return response.data
})
@ -13,20 +13,20 @@ export default {
uploadPhoto (summitCode, file, progress, cancelToken) {
let formData = new FormData()
formData.append('photo', file)
return this.axiosAuth.post('https://api.sotl.as/photos/summits/' + summitCode + '/upload', formData, {
return this.axiosAuth.post(process.env.VUE_APP_API_URL + '/photos/summits/' + summitCode + '/upload', formData, {
headers: { 'Content-Type': 'multipart/form-data' },
onUploadProgress: progress,
cancelToken
})
},
deletePhoto (summitCode, filename) {
return this.axiosAuth.delete('https://api.sotl.as/photos/summits/' + summitCode + '/' + filename)
return this.axiosAuth.delete(process.env.VUE_APP_API_URL + '/photos/summits/' + summitCode + '/' + filename)
},
editPhoto (summitCode, filename, data) {
return this.axiosAuth.post('https://api.sotl.as/photos/summits/' + summitCode + '/' + filename, data)
return this.axiosAuth.post(process.env.VUE_APP_API_URL + '/photos/summits/' + summitCode + '/' + filename, data)
},
reorderPhotos (summitCode, filenames) {
return this.axiosAuth.post('https://api.sotl.as/photos/summits/' + summitCode + '/reorder', { filenames })
return this.axiosAuth.post(process.env.VUE_APP_API_URL + '/photos/summits/' + summitCode + '/reorder', { filenames })
}
}
}

Wyświetl plik

@ -12,7 +12,7 @@ export default {
if (mapServerOverride && mapServerOverride !== 'test') {
this.mapServer = mapServerOverride
} else {
axios.get('https://api.sotl.as/map_server')
axios.get(process.env.VUE_APP_API_URL + '/map_server')
.then(response => {
if (response.data.mapServer) {
this.mapServer = response.data.mapServer

Wyświetl plik

@ -2,9 +2,9 @@ export default {
methods: {
photoSrc (photo, size) {
if (size === 'original') {
return 'https://sotlas-photos.s3.eu-central-003.backblazeb2.com/original/' + photo.filename
return process.env.VUE_APP_PHOTOS_ORIGINAL_URL + '/' + photo.filename
} else {
return 'https://images.sotl.as/photos/' + size + '/' + photo.filename.substring(0, 2) + '/' + photo.filename
return process.env.VUE_APP_PHOTOS_URL + '/' + size + '/' + photo.filename.substring(0, 2) + '/' + photo.filename
}
}
}

Wyświetl plik

@ -5,7 +5,7 @@ export default {
mixins: [ssoauth],
methods: {
loadActivations (callsign) {
return axios.get('https://api.sotl.as/activations/' + callsign)
return axios.get(process.env.VUE_APP_API_URL + '/activations/' + callsign)
.then(response => {
return response.data
})

Wyświetl plik

@ -200,7 +200,7 @@ function loadAlerts (noCache) {
if (noCache) {
params.noCache = 1
}
axios.get('https://api.sotl.as/alerts', { params })
axios.get(process.env.VUE_APP_API_URL + '/alerts', { params })
.then(response => {
store.commit('setAlerts', response.data)
})
@ -209,7 +209,7 @@ function loadAlerts (noCache) {
loadAlerts(false)
setInterval(loadAlerts, ALERT_UPDATE_INTERVAL)
Vue.use(VueNativeSock, 'wss://api.sotl.as/ws', {
Vue.use(VueNativeSock, process.env.VUE_APP_WSS_URL + '/ws', {
format: 'json',
store,
reconnection: true,

Wyświetl plik

@ -340,7 +340,7 @@ export default {
this.databaseError = false
let loads = []
axios.get('https://api.sotl.as/activators/' + this.callsign)
axios.get(process.env.VUE_APP_API_URL + '/activators/' + this.callsign)
.then(response => {
if (response) {
this.activator = response.data

Wyświetl plik

@ -63,7 +63,7 @@ export default {
methods: {
loadData () {
this.loading = true
axios.get('https://api.sotl.as/activators/search', { params: { q: this.filter, skip: (this.curPage - 1) * this.perPage, limit: this.perPage, sort: this.sortField, sortDirection: this.sortDirection } })
axios.get(process.env.VUE_APP_API_URL + '/activators/search', { params: { q: this.filter, skip: (this.curPage - 1) * this.perPage, limit: this.perPage, sort: this.sortField, sortDirection: this.sortDirection } })
.then(response => {
this.activators = response.data.activators
this.total = response.data.total

Wyświetl plik

@ -79,7 +79,7 @@ export default {
},
loadAssociation () {
this.loadingComponent = this.$buefy.loading.open({ canCancel: true })
axios.get('https://api.sotl.as/associations/' + this.associationCode)
axios.get(process.env.VUE_APP_API_URL + '/associations/' + this.associationCode)
.then(response => {
this.association = response.data
document.title = this.association.name + ' (' + this.associationCode + ') - SOTLAS'
@ -104,7 +104,7 @@ export default {
})
},
exportUrlPrefix () {
return `https://api.sotl.as/geoexport/associations/${this.associationCode}`
return process.env.VUE_APP_API_URL + '/geoexport/associations/' + this.associationCode
},
myActivationsPerRegion () {
if (!this.$store.state.myActivatedSummits) {

Wyświetl plik

@ -49,7 +49,7 @@ export default {
mounted () {
document.title = 'Associations - SOTLAS'
this.loadingComponent = this.$buefy.loading.open({ canCancel: true })
axios.get('https://api.sotl.as/associations/all')
axios.get(process.env.VUE_APP_API_URL + '/associations/all')
.then(response => {
this.associations = response.data
this.loadingComponent.close()

Wyświetl plik

@ -101,7 +101,7 @@ export default {
} catch (e) {}
this.showMap = true
} else {
axios.get('https://api.sotl.as/my_coordinates')
axios.get(process.env.VUE_APP_API_URL + '/my_coordinates')
.then(response => {
if (response.data.latitude && response.data.longitude) {
this.center = [response.data.longitude, response.data.latitude]
@ -346,7 +346,7 @@ export default {
})
},
fetchSummit (summitCode) {
return axios.get('https://api.sotl.as/summits/' + summitCode)
return axios.get(process.env.VUE_APP_API_URL + '/summits/' + summitCode)
.then(response => {
let summit = response.data
summit.photo = null
@ -354,7 +354,7 @@ export default {
})
},
fetchAssociation (associationCode) {
return axios.get('https://api.sotl.as/associations/' + associationCode)
return axios.get(process.env.VUE_APP_API_URL + '/associations/' + associationCode)
.then(response => {
return response.data
})

Wyświetl plik

@ -64,7 +64,7 @@ export default {
if (this.selectedAssociations.length > 0) {
associations = this.selectedAssociations.join('|')
}
axios.get('https://api.sotl.as/summits/recent_photos/' + associations + '/' + this.days, { params: recentPhotosParams })
axios.get(process.env.VUE_APP_API_URL + '/summits/recent_photos/' + associations + '/' + this.days, { params: recentPhotosParams })
.then(response => {
this.loadingComponent.close()
this.summits = response.data.slice(0, -1)
@ -72,7 +72,7 @@ export default {
})
},
loadAssociations () {
axios.get('https://api.sotl.as/associations/all')
axios.get(process.env.VUE_APP_API_URL + '/associations/all')
.then(response => {
this.associations = response.data
})

Wyświetl plik

@ -74,7 +74,7 @@ export default {
})
},
exportUrlPrefix () {
return `https://api.sotl.as/geoexport/regions/${this.regionCode}`
return process.env.VUE_APP_API_URL + '/geoexport/regions/' + this.regionCode
},
exportUrlParams () {
return (this.showInactive ? { inactive: 1 } : {})
@ -125,7 +125,7 @@ export default {
loadRegion () {
let loads = []
this.loadingComponent = this.$buefy.loading.open({ canCancel: true })
loads.push(axios.get('https://api.sotl.as/associations/' + this.associationCode)
loads.push(axios.get(process.env.VUE_APP_API_URL + '/associations/' + this.associationCode)
.then(response => {
this.association = response.data
document.title = this.region.name + ' (' + this.associationCode + '/' + this.region.code + ') - SOTLAS'
@ -136,7 +136,7 @@ export default {
}
}))
loads.push(axios.get('https://api.sotl.as/regions/' + this.regionCode)
loads.push(axios.get(process.env.VUE_APP_API_URL + '/regions/' + this.regionCode)
.then(response => {
let now = moment()
if (response.data.length === 0) {

Wyświetl plik

@ -78,12 +78,12 @@ export default {
let loads = []
let q = this.$route.query.q.trim()
this.loadingComponent = this.$buefy.loading.open({ canCancel: true })
loads.push(axios.get('https://api.sotl.as/activators/search', { params: { q, limit: this.limit } })
loads.push(axios.get(process.env.VUE_APP_API_URL + '/activators/search', { params: { q, limit: this.limit } })
.then(response => {
this.activators = response.data.activators
}))
loads.push(axios.get('https://api.sotl.as/summits/search', { params: { q, limit: this.limit } })
loads.push(axios.get(process.env.VUE_APP_API_URL + '/summits/search', { params: { q, limit: this.limit } })
.then(response => {
let now = moment()
response.data.forEach(summit => {

Wyświetl plik

@ -26,7 +26,7 @@ export default {
methods: {
loadHistory () {
// Fetch data from last 30 days
axios.get('https://api.sotl.as/solardata/history/720')
axios.get(process.env.VUE_APP_API_URL + '/solardata/history/720')
.then(response => {
this.loadingComponent.close()

Wyświetl plik

@ -344,10 +344,10 @@ export default {
}
// Make a dummy POST to the summit URL to invalidate the browser's cache for future page loads
axios.post('https://api.sotl.as/summits/' + this.summitCode)
axios.post(process.env.VUE_APP_API_URL + '/summits/' + this.summitCode)
}
loads.push(axios.get('https://api.sotl.as/summits/' + this.summitCode, options)
loads.push(axios.get(process.env.VUE_APP_API_URL + '/summits/' + this.summitCode, options)
.then(response => {
this.summit = response.data
document.title = this.summit.name + ' (' + this.summit.code + ') - SOTLAS'
@ -358,7 +358,7 @@ export default {
}
}))
loads.push(axios.get('https://api.sotl.as/associations/' + this.summitCode.substr(0, this.summitCode.indexOf('/')))
loads.push(axios.get(process.env.VUE_APP_API_URL + '/associations/' + this.summitCode.substr(0, this.summitCode.indexOf('/')))
.then(response => {
this.association = response.data
}))
@ -397,9 +397,9 @@ export default {
this.loadingComponent = this.$buefy.loading.open({ canCancel: false })
// Make a dummy POST to the summit URL to invalidate the browser's cache for future page loads
axios.post('https://api.sotl.as/summits/' + this.summitCode)
axios.post(process.env.VUE_APP_API_URL + '/summits/' + this.summitCode)
axios.get('https://api.sotl.as/summits/' + this.summitCode, { params: { t: new Date().getTime() } })
axios.get(process.env.VUE_APP_API_URL + '/summits/' + this.summitCode, { params: { t: new Date().getTime() } })
.then(response => {
this.summit = response.data
})