We’re running a vercel site with Sitecore 10.3 and JSS. I was getting errors about CORS origin like this:
Access to XMLHttpRequest at ‘https://{host}/sitecore/api/jss/track/event?sc_apikey={key}’ from origin ‘https://{host}’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status
So the JSS tracking wasn’t working. Started to dig in the Sitecore documentation on the tracking API and CORS origin but gave no answer to the problem:
https://doc.sitecore.com/xp/en/developers/hd/20/sitecore-headless-development/jss-tracking-api.html
Finally I found that the error was thrown because Sitecore.JSS.TrackerServiceEnabled is disabled by default. By setting it to true with a patch config the error disappeared.
<configuration>
<sitecore>
<settings>
<setting name="Sitecore.JSS.TrackerServiceEnabled" value="true" />
</settings>
</sitecore>
</configuration>