Skip to content
Discussion options

You must be logged in to vote

If you want your url to start with /api/, you just need to change the pattern to "^api/.+".
But if your pattern(regex) must contain (?, you can use re.compile():

import re
...
@app.get("/{url:path}")
async def frontend_page(request: Request, url: str = Path(..., pattern=re.compile(f"^(?!/api/).*"))):
...

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@YuriiMotov
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants
Converted from issue

This discussion was converted from issue #11755 on June 24, 2024 16:57.