How to access jsreport from cross domain
-
Hi,
Sorry if similar question has already been asked. I looked before posting and couldn't find any posting. My jsreport is running on port 3000 and my other application is on port 2000. I am trying to call jsreport from http://localhost:2000 and am setting up cors to allow origin/// define the jsreport middleware let jsreport = require('jsreport')({ express: { app :reportingApp, server: server }, appPath: "/reporting" }); app.use(cors({origin:'*'})); jsreport.init() .then(() => { console.log(`JSReport instance ${process.pid} started correctly.`); }).catch((e) => { console.error(e); });
but still I get this error
Error: Error during processing request: http://localhost:3000/reporting/api/report details: Error during rendering report: Cannot use 'in' operator to search for '$ref' in Project Id TypeError: Cannot use 'in' operator to search for '$ref' in Project Id
at recurse (C:\ifolder\iroot\jsReport\node_modules\jsreport\node_modules\jsreport-core\lib\render\resolveReferences.js:19:26)
at module.exports (C:\ifolder\iroot\jsReport\node_modules\jsreport\node_modules\jsreport-core\lib\render\resolveReferences.js:52:5)Is the error related to cross domain reference or its something else?
Thank you,
Rashmi
-
Hi, this error is not related to the cors.
jsreport fails here when parsing your input data.
We are parsing the input data in a way that we resolve references and circular structures in the input. This allows a smaller data transfer and more comfortable way to work with the data after wards. At this place it crashes. You likely have some invalid $ref props in your input json.Check this for some info
https://stackoverflow.com/questions/15312529/resolve-circular-references-from-json-objectJan
-
Thank you Jan. My input data was bad.