How to set/enable access-control-allow-origin in strapi middlewares.js in strapi V4

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

I have read several topics with related problems but non of them have solved my problem

here they solved it by changing middlewares.js

this person has the same problem.
this is the error I get in the client when fetching data from strapi API:

here is my middlewares.js:

module.exports = [
    name: "strapi::cors",
    config: {
      enabled: true,
      header: "*",
      origin: [

and after this I find you might need to change server.js as well so I change it to this:

module.exports = ({ env }) => ({
  url: env("MY_HEROKU_URL"),
  host: env("HOST", ""),
  port:"PORT", 1337),
  app: {
    keys: env.array("APP_KEYS"),
  name: "strapi::cors",
  config: {
    headers: [
    origin: [""],

and here is the network tap as you can see there is no access-control-allow-origin
in the response from strapi API: