From 78c07c78060db333286366bb014713b47042e692 Mon Sep 17 00:00:00 2001 From: Sirttas Date: Sat, 16 Sep 2023 16:04:30 +0200 Subject: [PATCH] proxy through ngnix --- .env.development | 3 --- .env.production | 3 --- nginx.conf | 22 ++++++++++++++++++++++ src/market/Market.vue | 6 +++++- src/service.ts | 13 ++++--------- vite.config.ts | 5 ----- 6 files changed, 31 insertions(+), 21 deletions(-) delete mode 100644 .env.development delete mode 100644 .env.production diff --git a/.env.development b/.env.development deleted file mode 100644 index cda15cb..0000000 --- a/.env.development +++ /dev/null @@ -1,3 +0,0 @@ -EVEAL_API_URL=/api/ -EVEPRAISAL_URL=/appraisal/ -ESI_URL=/esi/ diff --git a/.env.production b/.env.production deleted file mode 100644 index ebe88b3..0000000 --- a/.env.production +++ /dev/null @@ -1,3 +0,0 @@ -EVEAL_API_URL=https://api.eveal.shendai.rip/ -EVEPRAISAL_URL=https://appraise.imperium.nexus/ -ESI_URL=https://esi.evetech.net/latest/ diff --git a/nginx.conf b/nginx.conf index 1e36b6f..5bc8d15 100644 --- a/nginx.conf +++ b/nginx.conf @@ -5,4 +5,26 @@ server { location / { try_files $uri $uri/ $uri.html /index.html; } + location /api/ { + rewrite /api/(.*) /$1 break; + proxy_pass https://api.eveal.shendai.rip/; + proxy_ssl_server_name on; + proxy_set_header Host "api.eveal.shendai.rip"; + proxy_set_header X-Forwarded-Proto https; + + } + location /appraisal/ { + rewrite /appraisal/(.*) /$1 break; + proxy_pass https://appraise.imperium.nexus/; + proxy_ssl_server_name on; + proxy_set_header Host "appraise.imperium.nexus"; + proxy_set_header X-Forwarded-Proto https; + } + location /esi/ { + rewrite /esi/(.*) /latest/$1 break; + proxy_pass https://esi.evetech.net/; + proxy_ssl_server_name on; + proxy_set_header Host "esi.evetech.net"; + proxy_set_header X-Forwarded-Proto https; + } } \ No newline at end of file diff --git a/src/market/Market.vue b/src/market/Market.vue index 32661fa..6f9edc0 100644 --- a/src/market/Market.vue +++ b/src/market/Market.vue @@ -18,7 +18,7 @@ const addOrRelaod = async (type: MarketType) => { const typeID = type.id; const [history, price] = await Promise.all([ getHistory(jitaId, typeID), - evepraisalAxiosInstance.post('/appraisal.json?market=jita&persist=no', type.name) + evepraisalAxiosInstance.post(`/appraisal.json?market=jita&persist=no&raw_textarea=${type.name}`) ]); const item = { type, @@ -45,6 +45,10 @@ const addItem = async () => { watch(items, itms => itemsStorage.value = itms.map(i => ({ typeID: i.type.id, history: i.history }))); onMounted(async () => { + if (itemsStorage.value.length === 0) { + return; + } + const types = await getMarketTypes(itemsStorage.value.map(i => i.typeID)); const prices: any = (await evepraisalAxiosInstance.post(`/appraisal.json?market=jita&persist=no&raw_textarea=${types.map(t => t.name).join("%0A")}`)).data; diff --git a/src/service.ts b/src/service.ts index f2037be..5a054f3 100644 --- a/src/service.ts +++ b/src/service.ts @@ -1,11 +1,7 @@ import axios from 'axios'; -const evealApiUrl = process.env.EVEAL_API_URL; -const evepraisalUrl = process.env.EVEPRAISAL_URL; -const esiUrl = process.env.ESI_URL; - export const apiAxiosInstance = axios.create({ - baseURL: evealApiUrl, + baseURL: '/api/', headers: { 'accept': 'application/json', "Content-Type": "application/json" @@ -13,7 +9,7 @@ export const apiAxiosInstance = axios.create({ }) export const evepraisalAxiosInstance = axios.create({ - baseURL: evepraisalUrl, + baseURL: '/appraisal/', headers: { 'accept': 'application/json', "Content-Type": "application/json" @@ -21,10 +17,9 @@ export const evepraisalAxiosInstance = axios.create({ }) export const esiAxiosInstance = axios.create({ - baseURL: esiUrl, + baseURL: '/esi/', headers: { 'accept': 'application/json', - "Content-Type": "application/json", - "User-Agent": "eveal (eveal.shendai.rip calloch.gael@gmail.com)" + "Content-Type": "application/json" }, }) diff --git a/vite.config.ts b/vite.config.ts index e42fda2..1095a24 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,11 +14,6 @@ export default defineConfig(({ mode }) => { }, extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'] }, - define: { - 'process.env.EVEAL_API_URL': JSON.stringify(env.EVEAL_API_URL), - 'process.env.EVEPRAISAL_URL': JSON.stringify(env.EVEPRAISAL_URL), - 'process.env.ESI_URL': JSON.stringify(env.ESI_URL), - }, server: { port: 3000, strictPort: true,