Try to call two API from the react js front-end deployed in IC.
One api is working well and other one is throwing this error.
Any headsup
Here is the code for the node server https://codeshare.io/oQM9Rg
This is running in the port 5050 https://89.117.52.115:5050/
require(‘dotenv’).config();
const express = require(‘express’);
const cors = require(‘cors’);
const app = express();
const requestIp = require(‘request-ip’)
const https = require(‘https’);
const { getAllAssets, confirmAssets, getConfirmedAssets } = require(‘./all-assets’);
const fs = require(‘fs’);
const options = {
headers: {‘Access-Control-Allow-Origin’: ‘*’},
key: fs.readFileSync(‘server.key’),
cert: fs.readFileSync(‘server.crt’)
};
const httpsServer = https.createServer(options,app);
// Express middleware
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
// Home Router
app.get(‘/’, (req, res, next) => {
var clientIp = requestIp.getClientIp(req)
console.log(clientIp);
res.setHeader(‘Access-Control-Allow-Origin’, ‘*’);
res.send(‘Hello world’);
})
app.get(/api/${process.env.APP_VERSION}/all_assests/:address
, getAllAssets, confirmAssets, getConfirmedAssets);
// Error handler
app.use((req, res, next) => {
const err = new Error(‘not found’);
err.status = 404;
next(err)
})
app.use((err, req, res, next) => {
res.status(err.status || 500);
res.send({
success: false,
status: err.status || 500,
message: err.message
})
})
httpsServer.listen(process.env.APP_PORT, () => {
console.log(Server is running on Port ${process.env.APP_PORT}
);
})