"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.corsHandling = corsHandling;

// eslint-disable-next-line no-unused-vars
function corsHandling(app, options) {
  app.use((req, res, next) => {
    // console.log('origin', req.get('origin'));
    res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*'); // res.setHeader('Access-Control-Allow-Origin', req.get('origin'));

    res.setHeader('Access-Control-Allow-Private-Network', true);
    res.setHeader('Access-Control-Allow-Credentials', true);

    if (req.get('Access-Control-Request-Headers')) {
      res.setHeader('Access-Control-Allow-Headers', req.get('Access-Control-Request-Headers'));
    }

    if (req.get('Access-Control-Request-Method')) {
      res.setHeader('Access-Control-Allow-Methods', req.get('Access-Control-Request-Method'));
    }

    next();
  });
  app.options('/*', (req, res) => {
    res.send('Ok');
  });
}