Created
January 25, 2019 10:57
-
-
Save aykutyaman/f15cd7cea2bb815c88aa692c352d2899 to your computer and use it in GitHub Desktop.
Simple node.js server example with cors enabled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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