CORS error when requesting access token

I am following the docs on how to request for token using outh2 here:

import axios from "axios"
import qs from "qs"

const client_id = "<client_id>"
const client_secret = "<secret>"

const instance = axios.create({
  baseURL: ""

const config = {
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'

const body = qs.stringify({
  grant_type: "client_credentials"

// All requests using this instance will have an access token automatically added"/auth/realms/main/protocol/openid-connect/token", body, config).then(resp => {
  Object.assign(instance.defaults, {headers: {authorization: `Bearer ${}`}})

, however, I get an error:’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.