Skip to content

Instantly share code, notes, and snippets.

@cramhead
Created April 1, 2018 22:52
Show Gist options
  • Save cramhead/ef49ef9cc10afc7f6cf840b828c97dbd to your computer and use it in GitHub Desktop.
Save cramhead/ef49ef9cc10afc7f6cf840b828c97dbd to your computer and use it in GitHub Desktop.
Index.js file with cors enabled
import express from 'express'
import cors from 'cors'
const PORT = process.env.PORT || 3000
const app = express();
app.use('*', cors()) // todo: Add more restrictions
app.use('/', (req, res) => {
res.send(`Server says ${(new Date).toString()}`)
})
app.listen(PORT, () => {
console.log(`Server running at http://127.0.0.1:${PORT}/`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment