Skip to content

Instantly share code, notes, and snippets.

@aykutyaman
Created January 25, 2019 10:57
Show Gist options
  • Save aykutyaman/f15cd7cea2bb815c88aa692c352d2899 to your computer and use it in GitHub Desktop.
Save aykutyaman/f15cd7cea2bb815c88aa692c352d2899 to your computer and use it in GitHub Desktop.
Simple node.js server example with cors enabled
const http = require('http')
const Countries = [
'Turkey', 'Italy', 'Germany'
]
const app = http.createServer((req, res) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.writeHead(200, { 'Content-Type': 'application/json' })
res.end(JSON.stringify(Countries));
})
app.listen(3001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment