From 52cfb10ea19a16ae3afcaae946ef4926ebc2ce3b Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 18 Jul 2019 19:00:07 +0300 Subject: [PATCH] cors --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5b3d2b0..06287e9 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,11 @@ const express = require('express') const app = express() app.use(express.json()) +app.use(function(req, res, next) { + res.header("Access-Control-Allow-Origin", "*"); // update to match the domain you will make the request from + res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); + next(); +}); const { netId, rpcUrl, privateKey, mixerAddress, defaultGasPrice } = require('./config') const { fetchGasPrice, isValidProof } = require('./utils') @@ -54,7 +59,7 @@ app.post('/relay', async (req, resp) => { // TODO: nonce }) result.once('transactionHash', function(hash){ - resp.send({ transaction: hash }) + resp.json({ txHash: hash }) }).on('error', function(e){ console.log(e) resp.status(400).send('Proof is malformed')