From e964e5135a00fb3e72089334fc1f993d8106148f Mon Sep 17 00:00:00 2001 From: poma Date: Fri, 18 Dec 2020 23:53:35 +0300 Subject: [PATCH] fix cors --- src/server.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/server.js b/src/server.js index 587f906..8516a7d 100644 --- a/src/server.js +++ b/src/server.js @@ -8,6 +8,13 @@ const { isAddress } = require('web3-utils') const app = express() app.use(express.json()) +// Add CORS headers +app.use((req, res, next) => { + res.header('Access-Control-Allow-Origin', '*') + res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept') + next() +}) + // Log error to console but don't send it to the client to avoid leaking data app.use((err, req, res, next) => { if (err) { @@ -17,13 +24,6 @@ app.use((err, req, res, next) => { next() }) -// Add CORS headers -app.use((req, res, next) => { - res.header('Access-Control-Allow-Origin', '*') - res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept') - next() -}) - app.get('/', status.index) app.get('/v1/status', status.status) app.get('/v1/jobs/:id', status.getJob)