Problems in connecting react frontend and express server backend apis using axios (CORS problems)

Just like the title says I'm having problems connecting react frontend which runs on port 3000 with express that runs on 8080 port. The error I'm getting here is => Access to XMLHttpRequest at 'http://localhost:8080/api/test/all' from origin 'http://localhost:3000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost: 3000', but only one is allowed. I know from the description of the error that there is problem with cors but my backend is working properly when I test it in postman.

Here is some code to get an idea:

Frontend part with axios:

import axios from 'axios';
import authHeader from './auth-header';

const API_URL = 'http://localhost:8080/api/test/';

class UserService {
  getPublicContent() {
  return axios.get(API_URL + 'all');
 }
}

export default new UserService();

And here is my backend part : server.js

const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");

const app = express();


var corsOptions = {
    origin : "http://localhost: 3000",
}



app.use(cors(corsOptions));

app.use(bodyParser.json());

require('./routes/auth.routes')(app);
require('./routes/user.routes')(app);

app.use(bodyParser.urlencoded({extended : true}));


const db = require("./models");
const Role = db.role;

app.get("/", (req, res) => {
    res.json({message: "Welcome to my application"});
})

here is the link I wanna access from my frontend part -> user.routes.js

const { authJwt } = require("../middleware");
const controller = require("../controllers/user.controller");

module.exports = function(app) {
  app.use(function(req, res, next) {
    res.header(
      "Access-Control-Allow-Headers",
      "x-access-token, Origin, Content-Type, Accept"
    );
    next();
  });

  app.get("/api/test/all", controller.allAccess);

I hope u guys have got an idea. Basically when I click a button on my frontend part it should trigger /api/test/all response from backend but cors is giving me trouble. I suppose I'm missing something with headers but can't find solution. Any kind of help is highly appriciated and thanks in advance.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum