Skip to content

Problem with app.storage / ui.run_with #4037

Closed Answered by falkoschindler
shato20 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @shato20,

It's currently not mentioned in the documentation, but the storage module requires the following two middlewares to be set:

fastapi_app.add_middleware(storage.RequestTrackingMiddleware)
fastapi_app.add_middleware(SessionMiddleware, secret_key='SECRET')

Here is an executable example:

import uvicorn
from fastapi import FastAPI, Request
from fastapi.responses import RedirectResponse
from starlette.datastructures import Headers
from starlette.middleware.sessions import SessionMiddleware
from nicegui import Client, app, storage, ui

fastapi_app = FastAPI()
fastapi_app.add_middleware(storage.RequestTrackingMiddleware)
fastapi_app.add_middleware(SessionMiddleware, secret_key='SECRET')…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@shato20
Comment options

@shato20
Comment options

@falkoschindler
Comment options

Answer selected by shato20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants