Skip to content

Commit 715dbd5

Browse files
committed
Replaced HTTP redirect on / to HTML redirect
Apple Pay Verification system seems unhappy with redirects on / when it is verifying domain. This ought to keep it happy while maintaining the feature for end users
1 parent 758dc74 commit 715dbd5

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

donation-api/src/donation_api/entrypoint.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from http import HTTPStatus
22

3-
from fastapi import FastAPI
3+
from fastapi import FastAPI, Response
44
from fastapi.middleware.cors import CORSMiddleware
5-
from fastapi.responses import PlainTextResponse, RedirectResponse
5+
from fastapi.responses import PlainTextResponse
66

77
from donation_api import stripe
88
from donation_api.__about__ import __description__, __title__, __version__
@@ -19,9 +19,26 @@ def create_app() -> FastAPI:
1919
)
2020

2121
@app.get("/")
22+
@app.head("/")
2223
async def _():
23-
"""Redirect to root of latest version of the API"""
24-
return RedirectResponse(f"{PREFIX}/", status_code=HTTPStatus.PERMANENT_REDIRECT)
24+
"""HTML Redirect to root of latest version of the API
25+
26+
Purposedly not an HTTP redirect as Apple Pay verification system
27+
doesnt like it (apparently)"""
28+
29+
return Response(
30+
f"""<!DOCTYPE html>
31+
<html>
32+
<head>
33+
<meta charset="utf-8">
34+
<meta http-equiv="refresh" content="0; url={PREFIX}/" />
35+
<title>Donation API</title>
36+
</head>
37+
<body>
38+
<p>Current version is located at <a href="{PREFIX}/">{PREFIX}/</a></p>
39+
</body>
40+
</html>"""
41+
)
2542

2643
# could be done on infra ; this is a handy shortcut
2744
if conf.merchantid_domain_association:

0 commit comments

Comments
 (0)