Skip to content

Commit

Permalink
redirect middleware: only use prefix for / urls
Browse files Browse the repository at this point in the history
fixes #1517
  • Loading branch information
rodja committed Aug 29, 2023
1 parent 3b3aed2 commit ec77362
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nicegui/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RedirectWithPrefixMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -> Response:
prefix = request.headers.get('X-Forwarded-Prefix', '')
response = await call_next(request)
if 'Location' in response.headers:
if 'Location' in response.headers and response.headers['Location'].startswith('/'):
new_location = prefix + response.headers['Location']
response.headers['Location'] = new_location
return response

0 comments on commit ec77362

Please sign in to comment.