Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Commit

Permalink
Allow CORS requests
Browse files Browse the repository at this point in the history
  • Loading branch information
stoneLeaf committed Jan 11, 2019
1 parent 02b2a55 commit 7b29741
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
const express = require('express')
const logger = require('./config/winston')
const cors = require('cors')

const app = express()

// Allowing cross origin resource sharing (CORS)
app.use(cors())

// Logging HTTP requests with Morgan
app.use(require('morgan')('dev', { stream: logger.stream }))

Expand Down
14 changes: 11 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"homepage": "https://github.com/stoneLeaf/timeflies-backend#readme",
"dependencies": {
"bcrypt": "^3.0.2",
"cors": "^2.8.5",
"express": "^4.16.4",
"jsonwebtoken": "^8.4.0",
"mongoose": "^5.3.14",
Expand Down
9 changes: 9 additions & 0 deletions test/api/v1/auth_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ describe('API v1 integration testing: authentication', function () {
return resetDatabase()
})

it('Should allow CORS', function () {
let params = factories.alphaLoginParams()
delete params.email
return requester.post(endpoint).send(params)
.then(function (res) {
expect(res).to.have.header('Access-Control-Allow-Origin', '*')
})
})

it('Should require an email', function () {
let params = factories.alphaLoginParams()
delete params.email
Expand Down

0 comments on commit 7b29741

Please sign in to comment.