diff --git a/backend/common/utils/whitelist.py b/backend/common/utils/whitelist.py index 2de8605d..c02dfe44 100644 --- a/backend/common/utils/whitelist.py +++ b/backend/common/utils/whitelist.py @@ -3,6 +3,7 @@ import re from typing import List, Pattern from common.core.config import settings wlist = [ + "/", "/docs", "/login/*", "*.json", diff --git a/backend/main.py b/backend/main.py index 1e93d345..21b4dce5 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1,6 +1,7 @@ +from fastapi.responses import FileResponse from fastapi.staticfiles import StaticFiles import sentry_sdk -from fastapi import FastAPI +from fastapi import FastAPI, Path from fastapi.routing import APIRoute from starlette.middleware.cors import CORSMiddleware from apps.api import api_router @@ -8,7 +9,8 @@ from apps.system.middleware.auth import TokenMiddleware from common.core.config import settings def custom_generate_unique_id(route: APIRoute) -> str: - return f"{route.tags[0]}-{route.name}" + tag = route.tags[0] if route.tags and len(route.tags) > 0 else "" + return f"{tag}-{route.name}" if settings.SENTRY_DSN and settings.ENVIRONMENT != "local": @@ -32,7 +34,11 @@ if settings.all_cors_origins: app.add_middleware(TokenMiddleware) app.include_router(api_router, prefix=settings.API_V1_STR) -app.mount("/", StaticFiles(directory='../frontend/dist'), name="static") +app.mount("/static", StaticFiles(directory='../frontend/dist'), name="static") + +@app.get("/", include_in_schema=False) +async def read_index(): + return FileResponse(path="../frontend/dist/index.html") if __name__ == "__main__": import uvicorn uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) \ No newline at end of file diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 963f75c0..26e7558e 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -1,4 +1,4 @@ -import { createRouter, createWebHistory } from 'vue-router' +import { createRouter, createWebHashHistory } from 'vue-router' import Layout from '@/components/layout/index.vue' import login from '@/views/login/index.vue' @@ -8,7 +8,7 @@ import dashboard from '@/views/dashboard/index.vue' import setting from '@/views/setting/index.vue' import { watchRouter } from './watch' const router = createRouter({ - history: createWebHistory(), + history: createWebHashHistory(), routes: [ { path: '/login',