Skip to content

Commit e7cb806

Browse files
Fix callable transformer example to correctly return transformed ASGI app
Co-Authored-By: Alek Petuskey <[email protected]>
1 parent db80539 commit e7cb806

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

docs/api-routes/overview.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,19 @@ app = rx.App(api_transformer=fastapi_app)
7979

8080
You can also provide a callable that transforms the ASGI app:
8181

82-
```python
82+
```python box
8383
import reflex as rx
84-
from starlette.middleware import Middleware
8584
from starlette.middleware.cors import CORSMiddleware
8685

87-
# Create a transformer function
86+
# Create a transformer function that returns a transformed ASGI app
8887
def add_cors_middleware(app):
89-
# Add CORS middleware to the app
90-
middleware = CORSMiddleware(
88+
# Wrap the app with CORS middleware and return the wrapped app
89+
return CORSMiddleware(
9190
app=app,
9291
allow_origins=["https://example.com"],
9392
allow_methods=["*"],
9493
allow_headers=["*"],
9594
)
96-
return middleware
9795

9896
# Create a Reflex app with the transformer
9997
app = rx.App(api_transformer=add_cors_middleware)

0 commit comments

Comments
 (0)