backend-plus 2.5.2-betha.17 → 2.5.2-betha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/backend-plus.js +15 -12
  2. package/package.json +1 -1
@@ -913,18 +913,21 @@ AppBackend.prototype.start = function start(opts){
913
913
  }).then(async function(){
914
914
  mainApp = express();
915
915
  //mainApp.use(cookieParser());
916
- const whitelist = ['localhost'].concat(be.config.server.allowedHosts||[]); // Agrega aquí los orígenes de tus aplicaciones
917
- const corsOptions = {
918
- origin: function (origin, callback) {
919
- if (whitelist.some((element)=>origin?.includes(element)) || !origin){
920
- callback(null, true);
921
- }else{
922
- callback(new Error('Not allowed by CORS'));
923
- }
924
- },
925
- credentials: true
926
- };
927
- if(be.config.server.useCors){
916
+ if(be.config.server.allowedHosts){
917
+ if(!Array.isArray(be.config.server.allowedHosts)){
918
+ throw Error('allowedHosts must be an Array')
919
+ }
920
+ const whitelist = ['localhost'].concat(be.config.server.allowedHosts);
921
+ const corsOptions = {
922
+ origin: function (origin, callback) {
923
+ if (whitelist.some((element)=>origin?.includes(element)) || !origin){
924
+ callback(null, true);
925
+ }else{
926
+ callback(new Error('Not allowed by CORS'));
927
+ }
928
+ },
929
+ credentials: true
930
+ };
928
931
  mainApp.use(cors(corsOptions));
929
932
  }
930
933
  mainApp.use(bodyParser.urlencoded({extended:true, limit: '50mb'}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backend-plus",
3
3
  "description": "Backend for the anti Pareto rule",
4
- "version": "2.5.2-betha.17",
4
+ "version": "2.5.2-betha.18",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/backend-plus",