"use strict";

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

var _express = _interopRequireDefault(require("express"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function corsHandleing(app, options) {
  const {
    contextURL,
    context
  } = 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);
    next();
  }).use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
  app.options('/*', (req, res) => {
    res.send('Ok');
  });
}