Skip to content

Commit

Permalink
Allowed cors
Browse files Browse the repository at this point in the history
  • Loading branch information
Duddino committed Nov 5, 2022
1 parent 69d09ad commit 721c3c3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ dotenv.config();
checkEnv();
import express from "express";
import fetch from "node-fetch";
import cors from "cors";


const app = express()
app.use(cors());
const port = process.env["PORT"] || 3000;
const allowedRpcs = process.env["ALLOWED_RPCS"].split(",");

Expand Down Expand Up @@ -38,7 +41,7 @@ async function makeRpc(name, ...params){
return { status: imATeapot, response: obj.error.message };
} else {
const ok = 200;
return { status: ok, response: obj.result };
return { status: ok, response: JSON.stringify(obj.result) };
}
}catch(error){
if (error.errno === "ECONNREFUSED") {
Expand Down
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"homepage": "https://github.com/Shangaman/PivxNodeController#readme",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"node-fetch": "^3.2.10"
Expand Down

0 comments on commit 721c3c3

Please sign in to comment.