title: Getting a cross origin error. Using react/redux/node/express/mongodb
body: <p>I had this fixed by adding <code>app.use(cors())</code> on my index page of my server, but now that I have added a mongodb URI from mlab I seem to be having an issue with it. </p>
  
  <p>I am getting this error: <code>XMLHttpRequest cannot load http://localhost:3000/posts. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.</code></p>
  
  <p>Here is my index.js:</p>
  
  <pre><code>require('babel-core/register')({
    "presets":["es2015", "react", "stage-1"]
  });
  
  const express = require('express');
  const http = require('http');
  const bodyParser = require('body-parser');
  const morgan = require('morgan');
  const router = require('./router');
  const mongoose = require('mongoose');
  const cors = require('cors');
  const path = require('path');
  var favicon = require('serve-favicon');
  
  
  //DB setup
  mongoose.connect('mongodb://****:****@****:****/*****')
  mongoose.Promise = global.Promise;
  //App setup
  const app = express();
  app.use(express.static(__dirname + "../client/public"));
  // app.use(morgan('combined'));
  router(app);
  app.use(cors());
  app.use(bodyParser.json({type: '*/*'}))
  //Server setup
  const port = process.env.PORT || 3000;
  app.listen(port, function() {
    console.log('Server listening on: ', port);
  });
  </code></pre>