placeOrder api call in javascript not working: 403 (Forbidden) Invalid CORS request

const url = 'https://api.dhan.co/orders';
const options = {
  method: 'POST',
  headers: {
    'access-token': 'X',
    'Content-Type': 'application/json',
    Accept: 'application/json'
  },
  body: '{"dhanClientId":"string","correlationId":"string","transactionType":"BUY","exchangeSegment":"NSE_EQ","productType":"CNC","orderType":"LIMIT","validity":"DAY","tradingSymbol":"string","securityId":"string","quantity":-2147483648,"disclosedQuantity":-2147483648,"price":-3.402823669209385e+38,"triggerPrice":-3.402823669209385e+38,"afterMarketOrder":true,"amoTime":"OPEN","boProfitValue":-3.402823669209385e+38,"boStopLossValue":-3.402823669209385e+38,"drvExpiryDate":"string","drvOptionType":"CALL","drvStrikePrice":-3.402823669209385e+38}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

POST https://api.dhan.co/orders 403 (Forbidden)

“Invalid CORS request” is not valid JSON

Access to fetch at ‘https://api.dhan.co/orders’ from origin ‘null’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled

placeOrder api call in javascript not working: 403 (Forbidden) Invalid CORS request @Hardik Can you check this ASAP?

Hello @Priyadarshan_Patel

Welcome to Dhan Community! Glad to know you are exploring Dhan APIs.

We do have CORS policy enabled, which do not allow web based API requests. If you have any specific request, you can drop us mail at api@dhan.co.