Skip to content

Instantly share code, notes, and snippets.

@ronaiza-cardoso
Created February 6, 2017 15:58
Show Gist options
  • Save ronaiza-cardoso/360465e1c0942647e6b6b2d657ee4c9b to your computer and use it in GitHub Desktop.
Save ronaiza-cardoso/360465e1c0942647e6b6b2d657ee4c9b to your computer and use it in GitHub Desktop.
Simple nodejs server to ionic apps
/**
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