Skip to content

Commit 84c91ca

Browse files
Zachery Thomas RichardetZachery Thomas Richardet
authored andcommitted
fix up some urls for deployment
1 parent f8720cd commit 84c91ca

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

src/components/PrecomputedExamples.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ const displayGeoJSON = (geojson: GeoJSONResponse) => {
8888
const handleExampleRequest = async () => {
8989
isProcessing.value = true
9090
message.value = { type: 'loading', text: 'Processing example...' }
91-
91+
const apiBaseUrl = import.meta.env.PROD ? import.meta.env.VITE_API_BASE_URL : '/api'
9292
try {
9393
const token = generateJWT()
94-
const response = await fetch(`${import.meta.env.VITE_API_BASE_URL}/example`, {
94+
const response = await fetch(`${apiBaseUrl}/example`, {
9595
method: 'PUT',
9696
headers: {
9797
'Content-Type': 'application/json',

src/components/RunInference.vue

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ const handleCompareTiles = async () => {
179179
const token = generateJWT()
180180
181181
// Create project
182-
const createResponse = await fetch(`${import.meta.env.VITE_API_BASE_URL}/projects`, {
182+
const apiBaseUrl = import.meta.env.PROD ? import.meta.env.VITE_API_BASE_URL : '/api'
183+
184+
const createResponse = await fetch(`${apiBaseUrl}/projects`, {
183185
method: 'POST',
184186
headers: {
185187
'Content-Type': 'application/json',
@@ -217,7 +219,7 @@ const handleCompareTiles = async () => {
217219
const formData = new FormData()
218220
formData.append('file', imageBlob)
219221
220-
return fetch(`${import.meta.env.VITE_API_BASE_URL}/projects/${projectId}/images/a`, {
222+
return fetch(`${apiBaseUrl}/projects/${projectId}/images/a`, {
221223
method: 'PUT',
222224
headers: {
223225
'Access-Control-Allow-Origin': '*',
@@ -233,7 +235,7 @@ const handleCompareTiles = async () => {
233235
const formData = new FormData()
234236
formData.append('file', imageBlob)
235237
236-
return fetch(`${import.meta.env.VITE_API_BASE_URL}/projects/${projectId}/images/b`, {
238+
return fetch(`${apiBaseUrl}/projects/${projectId}/images/b`, {
237239
method: 'PUT',
238240
headers: {
239241
'Access-Control-Allow-Origin': '*',
@@ -257,29 +259,26 @@ const handleCompareTiles = async () => {
257259
}
258260
const {
259261
models: [{ id: modelId }],
260-
} = await fetch(`${import.meta.env.VITE_API_BASE_URL}`, {
262+
} = await fetch(`${apiBaseUrl}`, {
261263
headers: {
262264
'Access-Control-Allow-Origin': '*',
263265
Authorization: `Bearer ${token}`,
264266
},
265267
}).then((res) => res.json())
266268
267269
// Run inference
268-
const inferenceResponse = await fetch(
269-
`${import.meta.env.VITE_API_BASE_URL}/projects/${projectId}/inference`,
270-
{
271-
method: 'PUT',
272-
headers: {
273-
'Content-Type': 'application/json',
274-
Authorization: `Bearer ${token}`,
275-
},
276-
body: JSON.stringify({
277-
model: modelId,
278-
bbox: drawnExtent.value ?? [0, 0, 0, 0],
279-
images: [firstTile.thumbnailUrl, secondTile.thumbnailUrl],
280-
}),
270+
const inferenceResponse = await fetch(`${apiBaseUrl}/projects/${projectId}/inference`, {
271+
method: 'PUT',
272+
headers: {
273+
'Content-Type': 'application/json',
274+
Authorization: `Bearer ${token}`,
281275
},
282-
)
276+
body: JSON.stringify({
277+
model: modelId,
278+
bbox: drawnExtent.value ?? [0, 0, 0, 0],
279+
images: [firstTile.thumbnailUrl, secondTile.thumbnailUrl],
280+
}),
281+
})
283282
284283
if (!inferenceResponse.ok) {
285284
throw new Error(`Failed to run inference: ${inferenceResponse.statusText}`)
@@ -288,15 +287,12 @@ const handleCompareTiles = async () => {
288287
// Start polling for project status
289288
const pollInterval = setInterval(async () => {
290289
try {
291-
const statusResponse = await fetch(
292-
`${import.meta.env.VITE_API_BASE_URL}/projects/${projectId}`,
293-
{
294-
headers: {
295-
'Access-Control-Allow-Origin': '*',
296-
Authorization: `Bearer ${token}`,
297-
},
290+
const statusResponse = await fetch(`${apiBaseUrl}/projects/${projectId}`, {
291+
headers: {
292+
'Access-Control-Allow-Origin': '*',
293+
Authorization: `Bearer ${token}`,
298294
},
299-
)
295+
})
300296
if (!statusResponse.ok) {
301297
throw new Error(`Failed to fetch project status: ${statusResponse.statusText}`)
302298
}
@@ -307,15 +303,12 @@ const handleCompareTiles = async () => {
307303
clearInterval(pollInterval)
308304
309305
// Fetch inference results
310-
const resultsResponse = await fetch(
311-
`${import.meta.env.VITE_API_BASE_URL}/projects/${projectId}/inference`,
312-
{
313-
headers: {
314-
'Access-Control-Allow-Origin': '*',
315-
Authorization: `Bearer ${token}`,
316-
},
306+
const resultsResponse = await fetch(`${apiBaseUrl}/projects/${projectId}/inference`, {
307+
headers: {
308+
'Access-Control-Allow-Origin': '*',
309+
Authorization: `Bearer ${token}`,
317310
},
318-
)
311+
})
319312
if (!resultsResponse.ok) {
320313
throw new Error(`Failed to fetch inference results: ${resultsResponse.statusText}`)
321314
}

vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ export default defineConfig(({ mode }) => {
1717
'@': fileURLToPath(new URL('./src', import.meta.url)),
1818
},
1919
},
20-
base: env.VITE_BASE_URL || '/',
20+
base: mode === 'production' ? '/ftw-inference-app/' : '/',
2121
optimizeDeps: {
2222
include: ['ol/ol.css'],
2323
},
2424
server: {
2525
port: 5173,
2626
host: true,
27+
proxy: {
28+
'/api': {
29+
target: env.VITE_API_BASE_URL,
30+
changeOrigin: true,
31+
rewrite: (path) => path.replace(/^\/api/, ''),
32+
},
33+
},
2734
},
2835
}
2936
})

0 commit comments

Comments
 (0)