Created
February 6, 2017 15:58
-
-
Save ronaiza-cardoso/360465e1c0942647e6b6b2d657ee4c9b to your computer and use it in GitHub Desktop.
Simple nodejs server to ionic apps
This file contains 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
/** | |
On your package.json just put `"npm start": "node server.js"` and deploy your application to heroku | |
**/ | |
'use strict' | |
const express = require('express') | |
const app = express() | |
const PORT = process.env.PORT || 8000 | |
app.use(express.static('www')); | |
app.use((req, res, next) => { | |
res.header('Access-Control-Allow-Origin', '*') | |
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept') | |
next() | |
}) | |
app.listen(PORT, () => { | |
console.log(`Express Server is listening on port: ${PORT}`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment