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: "https://services.sentinel-hub.com"
})

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

const body = qs.stringify({
  client_id,
  client_secret,
  grant_type: "client_credentials"
})


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

, however, I get an error:
https://services.sentinel-hub.com/auth/realms/main/protocol/openid-connect/token’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.