export default (app, origin = 'http://localhost:8080') => {
  app.use((req, res, next) => {
    res
      .header('Access-Control-Allow-Origin', origin)
      .header('Access-Control-Allow-Method', 'POST')
      .header('Access-Control-Allow-Headers', 'content-type')

    next()
  })

  app.options('*', (req, res) => {
    res.status(204). send()
  })
}
