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:
parent
0c5bd4dcb9
commit
0f6b92617c
@ -6,10 +6,18 @@ const request = require('request')
|
|||||||
|
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
server.use(cors())
|
|
||||||
server.listen(4430)
|
server.listen(4430)
|
||||||
server.use(bodyParser.json())
|
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
|
// Zoho APIs
|
||||||
//
|
//
|
||||||
@ -20,6 +28,8 @@ const sendRequest = (options, res) => {
|
|||||||
request(options, (error, response, body) => {
|
request(options, (error, response, body) => {
|
||||||
if (error) res.send(error)
|
if (error) res.send(error)
|
||||||
|
|
||||||
|
// just pass through whatever we get from the APIs
|
||||||
|
// as the response
|
||||||
res.send(body)
|
res.send(body)
|
||||||
res.sendStatus(response.statusCode)
|
res.sendStatus(response.statusCode)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user