Skip to content

Commit

Permalink
Added cors middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
zenodeapp committed Feb 7, 2024
1 parent c2be2ed commit a735120
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const axios = require("axios");
const cors = require("cors");
const express = require("express");
require("dotenv").config();

Expand All @@ -7,6 +8,9 @@ const API = process.env.API_ENDPOINT;
const PORT = process.env.PORT || 3000;
const DIVIDE_BY = `1e${process.env.COIN_DECIMALS || 1}`;

// Use cors middleware to enable CORS
app.use(cors());

async function fetchData(endpoint) {
try {
const response = await axios.get(`${API}${endpoint}`);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"dependencies": {
"axios": "^0.24.0",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.17.1"
}
Expand Down

0 comments on commit a735120

Please sign in to comment.