Cors Error when generating access token for SharePoint point online from a JavaScript application

Any help is much appreciated. I’m trying to save data from a html form to a list in SharePoint online. I’m using SharePoint REST API to add items to the list. Ajax call to generate access token is throwing cors error.

url: "",
type: "POST",
data: JSON.stringify({
"grant_type": "client_credentials",
"client_id": "<client_id>",
"client_secret": "<client_secret>",
"resource": "00000003-0000-0ff1-ce00-000000000000/site_url@tenant_id"
headers: {
"contentType": "application/x-www-form-urlencoded",
success: function() {},
error: function() {}

Note: This code returns an access token in postman. If I use that access token in SharePoint REST Api, I’m able to add data to list. So the challenge is generating access token from my javascript application instead of Postman.
I can’t use MSAL as I don’t want to register my app in Azure AD. I don’t want a temporary fix like using a chrome extension to fix cors error or modifying rewrite rules in IIS.

I’m new to SharePoint, so any insights on alternate approaches would also be helpful.