Cant calling API from my server because of CORs
12:34 09 Nov 2025

I am making a todo desktop app which run locally on user's device. I am using Electron Forge and ExpressJs. I use Thunderclient and Postman to test the APIs, everything works fine. But when I make a request using axios through frontend, I get strict-origin-when-cross-origin error. I have configured cors for my server:

server.use(
  cors({
    origin: '*',
    methods: ['GET', 'POST'],
    allowedHeaders: ['Content-Type', 'Authorization']
  })
)

server.listen(port, '0.0.0.0', () => {
  console.log(`API server running at http://localhost:4000`)
})

It still not working. But when I try changing the port to 80, everything works fine. Can someone explain for me why it happens and how can I change to custom port? Thank you very much. Sorry for my bad writing.

javascript reactjs express electron cors