developmentseed / developmentseed/scoreboard

API lacks CORS headers

Open
#33 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
27
Forks
8
PR merge metrics
No merged PRs in 30d

Description

After changing https://github.com/developmentseed/scoreboard/blob/e8e6f598bd28d75eb1d40dc22fb5e1094a09b2c5/frontend/src/utils/api.js#L6 to point to `http://localhost:5000/scoreboard`, the front-end is still unable to load any data due to a lack of CORS headers.

Proposed change:

```patch
diff --git i/api/package.json w/api/package.json
index b503fb1..f92bc3e 100644
--- i/api/package.json
+++ w/api/package.json
@@ -25,6 +25,7 @@
"@heroku/foreman": "git+https://github.com/heroku/node-foreman.git",
"body-parser": "^1.18.3",
"compression": "^1.7.1",
+ "cors": "^2.8.4",
"express": "^4.16.3",
"express-boom": "^2.0.0",
"express-promise-router": "^2.0.0",
diff --git i/api/src/index.js w/api/src/index.js
index d8b9cdf..7dad586 100644
--- i/api/src/index.js
+++ w/api/src/index.js
@@ -4,6 +4,7 @@
const express = require('express')
const bodyParser = require('body-parser')
const boom = require('express-boom')
+const cors = require('cors')
const session = require('express-session')
const compression = require('compression')
const YAML = require('yamljs')
@@ -24,6 +25,7 @@ const { passport, authRouter } = require('./passport')
const swaggerDocument = YAML.load('./docs/api.yml')
swaggerDocument.info.version = pckg.version

+app.use(cors())
app.use(bodyParser.json())
app.use(compression())
app.use(boom())
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.