feat(ui): add error handling, flash messages and SEO optimization
- Add custom error pages (404, 403, 500) with user-friendly messages
- Add flash message system with signed cookies for security
- Add toast notifications with auto-dismiss and manual close
- Add comprehensive SEO meta tags (description, keywords, OG, Twitter)
- Add canonical URLs for SEO
- Update routes to use slug-based URLs (/posts/{slug} instead of /posts/{id})
- Add Open Graph and Twitter Card meta tags for social sharing
- Add favicon SVG
- Update all templates with proper meta tags and URLs
- Add error handlers registration in main.py
- Add flash middleware for request handling
- Install itsdangerous dependency
This commit is contained in:
10
app/main.py
10
app/main.py
@@ -26,6 +26,8 @@ from app.infrastructure.di.providers import (
|
||||
from app.presentation import router
|
||||
from app.presentation.web import auth_router
|
||||
from app.presentation.web import router as web_router
|
||||
from app.presentation.web.error_handlers import register_error_handlers
|
||||
from app.presentation.web.flash import setup_flash_manager
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
@@ -71,6 +73,14 @@ def app_factory() -> FastAPI:
|
||||
setup_dishka(container, app)
|
||||
|
||||
register_exception_handlers(app)
|
||||
register_error_handlers(app)
|
||||
|
||||
@app.middleware("http")
|
||||
async def flash_middleware(request, call_next):
|
||||
"""Middleware to setup flash manager for each request."""
|
||||
await setup_flash_manager(request)
|
||||
response = await call_next(request)
|
||||
return response
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
||||
Reference in New Issue
Block a user