1
0
mirror of https://github.com/oceanprotocol/webtasks synced 2024-11-24 02:55:13 +01:00

lock down with CORS

This commit is contained in:
Matthias Kretschmann 2018-06-22 13:05:58 +02:00
parent 0c5bd4dcb9
commit 0f6b92617c
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -6,10 +6,18 @@ const request = require('request')
const server = express()
server.use(cors())
server.listen(4430)
server.use(bodyParser.json())
//
// Allow requests from these domains only
//
const corsOptions = {
origin: ['https://oceanprotocol.com', /\.oceanprotocol\.com$/],
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
}
server.use(cors(corsOptions))
//
// Zoho APIs
//
@ -20,6 +28,8 @@ const sendRequest = (options, res) => {
request(options, (error, response, body) => {
if (error) res.send(error)
// just pass through whatever we get from the APIs
// as the response
res.send(body)
res.sendStatus(response.statusCode)
})