How can I create protected routes? #28
-
Hi, I'm learning reactpy and reactpy-routers with a simple to-do app. In this app, I'll have users that can see only your tasks and only authenticated users can see tasks. I already have a backend developed with FastAPI with a login endpoint that returns the access_token. So how can I protect my routes to allow only authenticated users? |
Beta Was this translation helpful? Give feedback.
Answered by
Archmonger
Nov 24, 2023
Replies: 1 comment 1 reply
-
Routes can be protected within the individual components that render those routes. For example, from reactpy import component, html
@component
def example():
if condition_is_met:
# You can either redirect via scripts or just return None.
return html.script('window.location.href = "/my_url/";')
return ... # Your ReactPy application |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Archmonger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Routes can be protected within the individual components that render those routes.
For example,