vite proxy to api redirect added

This commit is contained in:
zurdi zurdo
2023-03-17 13:09:25 +01:00
parent 45aa2e2613
commit 90cb69450b
6 changed files with 12 additions and 7 deletions

View File

@@ -19,19 +19,19 @@ igdbh: IGDBHandler = IGDBHandler()
dbh: DBHandler = DBHandler()
@app.get("/platforms/{slug}/roms")
@app.get("/api/platforms/{slug}/roms")
async def platforms(slug):
"""Returns roms data of the desired platform"""
return {'data': [Rom(*r) for r in dbh.get_roms(slug)]}
@app.get("/platforms")
@app.get("/api/platforms")
async def platforms():
"""Returns platforms data"""
return {'data': [Platform(*p) for p in dbh.get_platforms()]}
@app.get("/scan")
@app.get("/api/scan")
async def scan(overwrite: bool=False):
"""Scan platforms and roms and write them in database."""

View File

@@ -39,7 +39,7 @@ http {
# Backend api calls
location /api {
rewrite /api/(.*) /$1 break;
# rewrite /api/(.*) /$1 break;
proxy_pass http://localhost:5000/;
}
}

View File

@@ -1 +0,0 @@
VITE_BACK_PORT="5000"

View File

@@ -5,7 +5,6 @@ import { useRouter } from 'vue-router'
import { useTheme } from "vuetify";
// Props
const backPort = import.meta.env.VITE_BACK_PORT
const platforms = ref([])
const currentPlatformName = ref(localStorage.getItem('currentPlatformName') || "")
const currentPlatformSlug = ref(localStorage.getItem('currentPlatformSlug') || "")

View File

@@ -5,7 +5,6 @@ import { useRouter } from 'vue-router'
import { saveAs } from 'file-saver'
// Props
const backPort = import.meta.env.VITE_BACK_PORT
const roms = ref([])
const romsFiltered = ref([])
const currentFilter = ref('')

View File

@@ -36,6 +36,14 @@ export default defineConfig({
],
},
server: {
proxy: {
'/api': {
target: 'https://localhost:5000',
changeOrigin: true,
secure: false,
ws: true,
}
},
port: 3000,
},
})