Browse Source

cors

master
zeus 3 years ago
parent
commit
489fc230b8
  1. 23
      readmongo/swarmlab-app/src/run/app.js

23
readmongo/swarmlab-app/src/run/app.js

@ -11,6 +11,16 @@ const { DATABASE, COLLECTION, URL, REDIS, REDIS_PORT, PORT } = process.env;
const fs = require('fs');
const whitelist = [
"http://localhost:3000",
"http://localhost:8080",
"http://localhost:8085",
"http://localhost:3080",
"http://localhost:3081",
"http://localhost:3082",
"http://webclient.poc-datacollector_datacollector-net:8080",
"http://webclient.poc-datacollector_datacollector-net:8085",
];
const io = require("socket.io")(http, {
// pingTimeout: 30000,
// allowUpgrades: false,
@ -19,7 +29,8 @@ const io = require("socket.io")(http, {
// //transports: [ 'websocket', 'polling' ],
// transports: [ 'polling', 'websocket' ],
cors: {
origin: "http://localhost:8085",
origin: whitelist,
//origin: "http://localhost:8085",
methods: ["GET", "POST"],
allowedHeaders: ["my-custom-header"],
credentials: true,
@ -72,16 +83,6 @@ app.use(helmet());
const cors = require("cors");
const { MongoError } = require("mongodb");
const whitelist = [
"http://localhost:3000",
"http://localhost:8080",
"http://localhost:8085",
"http://localhost:3080",
"http://localhost:3081",
"http://localhost:3082",
"http://webclient.poc-datacollector_datacollector-net:8080",
"http://webclient.poc-datacollector_datacollector-net:8085",
];
const corsOptions = {
credentials: true,
methods: ["GET", "PUT", "POST", "DELETE", "OPTIONS"],

Loading…
Cancel
Save