How to proprely setup CORS OPTIONS headers response?

Hi,

I’ve been trying to get around the CORS 403 (forbidden) response to my third-party POST request.

Here’s the OPTIONS request that Chrome sends to my website:

OPTIONS /_functions/addUserLeaderboard/ HTTP/1.1 
Host: www.mywebsite.com 
Connection: keep-alive 
Access-Control-Request-Method: POST 
Origin: https://link_of_where_my_app_is_hosted.net 
Sec-Fetch-Dest: empty 
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36 Access-Control-Request-Headers: content-type Accept: */* 
Sec-Fetch-Site: cross-site 
Sec-Fetch-Mode: cors 
Referer: link_of_where_I_try_to_request.html Accept-Encoding: gzip, deflate, br 
Accept-Language: en-CA,en;q=0.9,fr-CA;q=0.8,fr;q=0.7,en-GB;q=0.6,en-US;q=0.5

And here is what I’ve got set up (accordingly to Corvid’s documentation) on my backend:


export function options_addUserLeaderboard(request) {
let headers = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "POST, GET, OPTIONS",
"Access-Control-Max-Age": "86400"
}
return response({"status": 204, "headers": headers});
}

Am I doing something wrong? I’ve been searching and struggling with this for three days and somehow can’t figure this out… Help with this would be really appreciated.

Is there any paid service I can call or write to in order to get help with Wix’s API? I’m really starting to desperate.