API returns 404 on OPTIONS CORS preflight

When attempting to make a cross origin request (in my case, creating a new post via /posts.json) the API returns ‘404 Not Found’ for some reason and therefore, OPTIONS preflight request fails.

Response headers:

HTTP/2 404 Not Found
date: Fri, 09 Apr 2021 17:59:03 GMT
content-encoding: gzip
content-type: text/html; charset=utf-8
status: 404 Not Found
x-request-id: f8378b677d9c0a44993289c4c06bcfa3
x-runtime: 0.054407

I have also seen this commit in the discourse github repository which should have fixed this issue but still, I have no idea why this happens.

Your help would be appreciated.