proxy redirect to api added in vite

This commit is contained in:
zurdi zurdo
2023-03-17 13:19:48 +01:00
parent 90cb69450b
commit ba30aa095f
5 changed files with 8 additions and 7 deletions

0
.github/actions/build.sh vendored Normal file → Executable file
View File

View File

@@ -19,19 +19,19 @@ igdbh: IGDBHandler = IGDBHandler()
dbh: DBHandler = DBHandler()
@app.get("/api/platforms/{slug}/roms")
@app.get("/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("/api/platforms")
@app.get("/platforms")
async def platforms():
"""Returns platforms data"""
return {'data': [Platform(*p) for p in dbh.get_platforms()]}
@app.get("/api/scan")
@app.get("/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,6 +1,6 @@
{
"name": "romm",
"version": "0.12",
"version": "0.13",
"private": true,
"scripts": {
"dev": "vite --host",

View File

@@ -38,10 +38,11 @@ export default defineConfig({
server: {
proxy: {
'/api': {
target: 'https://localhost:5000',
changeOrigin: true,
target: 'http://localhost:5000',
changeOrigin: false,
secure: false,
ws: true,
rewrite: (path) => path.replace(/^\/api/, ''),
}
},
port: 3000,