Network/ CORS error thrown when creating xlsx file
-
Hi, I want to pass a set of data containing 33 rows of records to the JSReport API to generate an xlsx file. Each row contains 17 columns and an image.
The error below is thrown when I try to pass 14 records. Everything works fine with 13 records.[Error from Chrome Inspect tool]( image url)
[Error from console]( image url)
Code:var jsReportPDF = await this.$axios.post('https://playground.jsreport.net/w/.......', { template: { shortid: '{{shortid}}' }, data: excel, options: { "reportName": "myfilename.xlsx",'Content-Disposition': 'attachment;filename=report.xlsx', "reports": { "async": true, "blobName": "myfilename" } } }, { responseType: 'arraybuffer', express: { "inputRequestLimit": "300mb" } } );
My initial guess is that the request limit has to be increased but it did not work.
for 13 records, the content length is 8860574 (which is approx. 9Mb?).Playground: https://playground.jsreport.net/w/hernglx/fkqo1UQc
The same data format can be found here, only that the number of data amounts to 33 on my side.
How do I solve this?
-
Try to use these in the axios options:
maxContentLength: Infinity
maxBodyLength: Infinity
See it here in our node.js client which uses axios as well.
-
Is this for remote jsreport server? Is there a way to do this if I want to use JSreport Online?
-
I don't understand what you mean. Please elaborate.
The jsreport nodejs client works with the on-prem version as well as with jsreportonline.
-
I'm not sure where to add the two lines of code you mentioned.
-
Like this for example
var jsReportPDF = await this.$axios.post('https://playground.jsreport.net/w/.......', { template: { shortid: '{{shortid}}' }, data: excel, options: { "reportName": "myfilename.xlsx",'Content-Disposition': 'attachment;filename=report.xlsx', "reports": { "async": true, "blobName": "myfilename" } } }, { responseType: 'arraybuffer', maxContentLength: Infinity, maxBodyLength: Infinity, express: { "inputRequestLimit": "300mb" } } );
-
I'm still getting a 413 + CORS error... This is my code:
var jsReportPDF = await this.$axios.post('https://playground.jsreport.net/...', { template: { shortid: '{{shortid}}' }, data: excel, options: { "reportName": "myfilename.xlsx",'Content-Disposition': 'attachment;filename=report.xlsx', "reports": { "async": true, "blobName": "myfilename" } } }, { responseType: 'arraybuffer', maxContentLength: Infinity, maxBodyLength: Infinity, express: { "inputRequestLimit": "300mb" } } );
Does it run smoothly on your side?