Skip to content

Commit ea027f7

Browse files
committed
fix other crash when redirecting
Signed-off-by: Sagar <sagargurung1001@gmail.com>
1 parent 916812d commit ea027f7

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

ex_app_run_script.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ export APP_PORT="9030"
55
export APP_HOST="127.0.0.1"
66
export APP_SECRET="12345"
77
export APP_VERSION="0.0.1"
8-
export AA_VERSION="3.1.1"
8+
export AA_VERSION="3.2.0"
99
export EX_APP_VERSION="0.0.1"
1010
export EX_APP_ID="openproject-nextcloud-app"
11-
export NEXTCLOUD_URL="http://localhost/stable30/index.php"
12-
export OP_BACKEND_URL="http://localhost:3000/stable30/index.php/apps/app_api/proxy/openproject-nextcloud-app"
11+
export NEXTCLOUD_URL="http://localhost/stable300/index.php"
12+
export OP_BACKEND_URL="http://localhost:3000/stable300/index.php/apps/app_api/proxy/openproject-nextcloud-app"
1313

1414
python3.10 lib/main.py

lib/main.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,16 @@ async def proxy_request_to_server(request: Request, path: str):
126126
headers=headers,
127127
content=payload,
128128
)
129+
129130

130131
if response.is_redirect and not response.status_code == 304:
131-
if url.endswith("/login") or "/two_factor_authentication/" in url or "/oauth/authorize" in url:
132-
if "/oauth/authorize" in url:
133-
response.headers["location"] = response.headers["location"]
134-
else:
135-
redirect_path = urlparse(response.headers["location"]).path
136-
redirect_url = get_nc_url() + redirect_path
137-
response.headers["location"] = redirect_url
138-
# fake 200 status code so that NC passes the response to the browser
139-
132+
if "location" in response.headers and "proxy/openproject-nextcloud-app" in response.headers["location"]:
133+
redirect_path = urlparse(response.headers["location"]).path
134+
redirect_url = get_nc_url() + redirect_path
135+
response.headers["location"] = redirect_url
140136
response.status_code = 200
137+
elif "oauth/authorize" in url:
138+
response.headers["location"] = response.headers["location"]
141139
else:
142140
headers["content-length"] = "0"
143141
response = await handle_redirects(

0 commit comments

Comments
 (0)