Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Vue 3 Web Build with FastAPI #1453

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions turbinia/api/routes/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,11 @@ async def web(request: Request):
raise HTTPException(status_code=404, detail='Not found')


@ui_router.get('/css/{catchall:path}', name='css', include_in_schema=False)
async def serve_css(request: Request):
"""Serves CSS content."""
static_content_path = pathlib.Path(_config.WEBUI_PATH).joinpath('dist/css')
path = request.path_params['catchall']
file = static_content_path.joinpath(path)
if os.path.exists(file):
return FileResponse(file)

raise HTTPException(status_code=404, detail='Not found')


@ui_router.get('/js/{catchall:path}', name='js', include_in_schema=False)
async def serve_js(request: Request):
"""Serves JavaScript content."""
static_content_path = pathlib.Path(_config.WEBUI_PATH).joinpath('dist/js')
@ui_router.get(
'/assets/{catchall:path}', name='assets', include_in_schema=False)
async def serve_assets(request: Request):
"""Serves assets content."""
static_content_path = pathlib.Path(_config.WEBUI_PATH).joinpath('dist/assets')
path = request.path_params['catchall']
file = static_content_path.joinpath(path)
if os.path.exists(file):
Expand Down
1 change: 0 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://cdn.jsdelivr.net/npm/@mdi/[email protected]/css/materialdesignicons.min.css" rel="stylesheet" />
<title>Turbinia</title>
</head>

Expand Down
4 changes: 2 additions & 2 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
<nav class="navbar">
<v-app-bar flat :elevation="1" >
<template v-slot:prepend>
<v-img src="./assets/turbinia-logo-mark.png" height="50" width="70"></v-img>
<v-img src="./turbinia-logo-mark.png" height="50" width="70"></v-img>
</template>
<v-app-bar-title>Turbinia</v-app-bar-title>
<v-spacer></v-spacer>
Expand Down
File renamed without changes
11 changes: 1 addition & 10 deletions web/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Plugins
import vue from '@vitejs/plugin-vue'
import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'
import ViteFonts from 'unplugin-fonts/vite'

// Utilities
import { defineConfig } from 'vite'
Expand All @@ -17,14 +16,6 @@ export default defineConfig({
vuetify({
autoImport: true,
}),
ViteFonts({
google: {
families: [{
name: 'Roboto',
styles: 'wght@100;300;400;500;700;900',
}],
},
}),
],
define: { 'process.env': {} },
resolve: {
Expand All @@ -44,7 +35,7 @@ export default defineConfig({
server: {
port: 3000,
proxy: {
'/api': {
'/web': {
target: 'http://localhost:8000',
changeOrigin: true,
},
Expand Down
Loading