When a JSON data source is served by a protected backend, you can attach custom HTTP headers to each data request.

Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
import { Viewer, Stimulsoft } from 'stimulsoft-reports-js-react/viewer';

function App() {
    var report = new Stimulsoft.Report.StiReport();
    report.loadFile('Reports/MasterDetail.mrt');

    report.onBeginProcessData = function (args) {
        if (args.database === 'JSON' && args.command === 'GetData') {
            // Add custom header to pass through backend server protection
            args.headers.push({ key: 'X-Auth-Token', value: '*YOUR TOKEN*' });
        }
    };

    var viewerOptions = new Stimulsoft.Viewer.StiViewerOptions();
    viewerOptions.appearance.fullScreenMode = true;

    return <Viewer options={viewerOptions} report={report} />;
}

export default App;

The onBeginProcessData event fires before every data request; pushing an entry onto args.headers (here an X-Auth-Token) lets the call pass through server-side protection.

Используя этот сайт, вы соглашаетесь на использование файлов Cookie для аналитики и персонализированного контента. Файлы Cookie хранят полезную информацию на вашем компьютере, чтобы помочь нам повысить эффективность и удобство использования. Для получения дополнительной информации, пожалуйста, прочтите Конфиденциальность и Использование Cookie.