Skip to content

Instantly share code, notes, and snippets.

@neight-allen
Created March 23, 2017 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neight-allen/f0dd5f3886e89a7c834c4940fdce9127 to your computer and use it in GitHub Desktop.
Save neight-allen/f0dd5f3886e89a7c834c4940fdce9127 to your computer and use it in GitHub Desktop.

Install the CORS package

npm i cors --save

In your server.js:

const cors = require('cors')

....

var corsOptions = {
  origin: '*',
  optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
}

app.use(cors(corsOptions))

app.options('*', cors(corsOptions))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment