Node.js
Follow this community to receive post notifications to your feed and rise to the Top Members list.
1 posts
1 members
2 years ago
Cors blocking access from my client application

I currently have both my client side and API being served on Heroku, but Cors is blocking access to my API. This is only happening in my production environment, as my local environments work as expected. I've tried multiple combinations of Cors policies in my API, and from each request that is sent from my client side, I am sending { withCredentials: true }. Below is the current code that I have in my app.js.


const express = require('express');
const cors = require('cors');

var app = express(); 

const options = {
  origin: 'https://myclientapp.com',
  credentials: 'true'
};

app.use(cors(options)); 

app.listen(process.env.PORT || 3000, () => {
  console.log(`Sever is listening on port: ${process.env.PORT}`);
});

Any help would be great