From 4b0720fac275597962dcb2749d0f29ec97e7d5e0 Mon Sep 17 00:00:00 2001 From: Matthias Veit Date: Tue, 17 Oct 2023 17:08:01 +0200 Subject: [PATCH] [fix] resolve the route (again) --- fixbackend/subscription/router.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fixbackend/subscription/router.py b/fixbackend/subscription/router.py index e6a71d70..270c8469 100644 --- a/fixbackend/subscription/router.py +++ b/fixbackend/subscription/router.py @@ -22,7 +22,7 @@ from functools import partial from typing import Callable -from fastapi import APIRouter, Form, Cookie, Response +from fastapi import APIRouter, Form, Cookie, Response, Request from starlette.responses import RedirectResponse from fixbackend.auth.depedencies import OptionalAuthenticatedUser, AuthenticatedUser @@ -41,7 +41,9 @@ def subscription_router(deps: FixDependencies) -> APIRouter: # Attention: Changing this route will break the AWS Marketplace integration! @router.post("/cloud/callbacks/aws/marketplace") async def aws_marketplace_fulfillment( - maybe_user: OptionalAuthenticatedUser, x_amzn_marketplace_token: str = Form(alias="x-amzn-marketplace-token") + request: Request, + maybe_user: OptionalAuthenticatedUser, + x_amzn_marketplace_token: str = Form(alias="x-amzn-marketplace-token"), ) -> Response: if user := maybe_user: # add marketplace subscription @@ -49,7 +51,7 @@ async def aws_marketplace_fulfillment( # load the app and show a message return RedirectResponse("/?message=aws-marketplace-subscribed") else: - add_url = router.url_path_for(AddUrlName) + add_url = request.scope["router"].url_path_for(AddUrlName) response = RedirectResponse(f"/auth/login?returnUrl={add_url}") response.set_cookie("fix-aws-marketplace-token", x_amzn_marketplace_token, secure=True, httponly=True) return response