My frontend, registered to the playlistmoodevaluator.com
domain on Cloudflare, routes to a React CRA-based app hosted on Render.
My backend, registered to the api.playlistmoodevaluator.com
subdomain on Cloudflare, routes to a FastAPI python backend hosted on Fly.io.
The first request to my backend fails with Reason: CORS header ‘Access-Control-Allow-Origin’ missing
, despite the fact that my FastAPI backend is configured with a CORS Middleware to accept requests from that frontend domain.
I ensured that my backend is configured to accept requests from my frontend, like so:
origins = [
"https://playlistmoodevaluator.com",
"https://www.playlistmoodevaluator.com",
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
Here is a screenshot of the error:
As you can see in the screenshot attached below, this exact origin (https://playlistmoodevaluator.com), is expected by my backend’s Middleware and should be accepted.
This process was working until I registered my domain with Cloudflare and started routing my traffic through my new domain.