Facing CORS error when I am trying to call QA graphql api's from the localhost nextjs application

My Apollo client looks like this and the link refers to qa domain url. I tried multiple options but nothing worked could someone suggest me on this.

const client = new ApolloClient({
link: httpLink, // qa domain graphql url
cache: new InMemoryCache(),
defaultOptions: defaultOptions,
headers: {
“Content-Type”: ‘application/json’,
“Access-Control-Allow-Origin”: ‘*’,
“Access-Control-Allow-Credentials”: “true”
},
});

and from server side my code looks like below.

import cors from ‘cors’
import express from ‘express’;
import { ApolloServer } from ‘apollo-server-express’;
import { ApolloServerPluginDrainHttpServer } from “apollo-server-core”;
import http from “http”;

async function startApolloServer(schema: any, resolvers: any) {
const app = express();
app.use(cors({origin:‘*’}) )

const httpServer = http.createServer(app);
const server = new ApolloServer({
typeDefs: schema,
resolvers,
//tell Express to attach GraphQL functionality to the server
plugins: [ApolloServerPluginDrainHttpServer({ httpServer })],
context: async ({ req }) => ({ dataSource })
}) ;
await server.start(); //start the GraphQL server.
server.applyMiddleware({ app });
await new Promise((resolve) =>
httpServer.listen({ port: 4000 }, resolve) //run the server on port 4000
);
console.log(Server ready at http://localhost:4000${server.graphqlPath});
}
//in the end, run the server and pass in our Schema and Resolver.
startApolloServer(typeDefs, resolvers);